#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

#25 in Data structures

Download history 1215/week @ 2018-07-02 1357/week @ 2018-07-09 1408/week @ 2018-07-16 1322/week @ 2018-07-23 1055/week @ 2018-07-30 945/week @ 2018-08-06 976/week @ 2018-08-13 753/week @ 2018-08-20 830/week @ 2018-08-27 953/week @ 2018-09-03 832/week @ 2018-09-10 996/week @ 2018-09-17 907/week @ 2018-09-24

4,901 downloads per month
Used in 34 crates (12 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##"


    
    

"##;

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

~206KB