#xml #parse #xmltree

xmltree

Parse an XML file into a simple tree-like structure

10 releases (6 breaking)

0.8.0 Feb 7, 2018
0.6.1 Sep 26, 2017
0.4.0 Mar 26, 2017
0.3.2 Apr 23, 2016
0.2.1 Aug 19, 2015

#91 in Parser tooling

Download history 510/week @ 2018-12-20 601/week @ 2018-12-27 1056/week @ 2019-01-03 932/week @ 2019-01-10 822/week @ 2019-01-17 569/week @ 2019-01-24 789/week @ 2019-01-31 980/week @ 2019-02-07 859/week @ 2019-02-14 972/week @ 2019-02-21 906/week @ 2019-02-28 1104/week @ 2019-03-07 1204/week @ 2019-03-14 1258/week @ 2019-03-21 1034/week @ 2019-03-28

4,901 downloads per month
Used in 39 crates (16 directly)

MIT license

12KB
219 lines

xmltree-rs

Documention

A small library for parsing an XML file into an in-memory tree structure.

Not recommended for large XML files, as it will load the entire file into memory.

https://crates.io/crates/xmltree

Usage

Add the following to your Cargo.toml file:

[dependencies]
xmltree = "0.7"

and this to yoru crate root:

extern crate xmltree;

Example

See the documentation for the latest version:

https://docs.rs/xmltree/


lib.rs:

A simple library for parsing an XML file into an in-memory tree structure

Not recommended for large XML files, as it will load the entire file into memory.

Example

use xmltree::Element;
use std::fs::File;

let data: &'static str = r##"
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<names>
    <name first="bob" last="jones" />
    <name first="elizabeth" last="smith" />
</names>
"##;

let mut names_element = Element::parse(data.as_bytes()).unwrap();

println!("{:#?}", names_element);
{
    // get first `name` element
    let name = names_element.get_mut_child("name").expect("Can't find name element");
    name.attributes.insert("suffix".to_owned(), "mr".to_owned());
}
names_element.write(File::create("result.xml").unwrap());


Dependencies

~210KB