elementtree

Crates.ioelementtree
lib.rselementtree
version1.2.3
sourcesrc
created_at2017-03-28 14:10:46.106442
updated_at2023-01-04 12:30:06.458677
descriptionParse an XML file into Python elementtree like structure
homepage
repositoryhttps://github.com/mitsuhiko/elementtree-rust
max_upload_size
id9180
size266,435
Armin Ronacher (mitsuhiko)

documentation

http://docs.rs/elementtree

README

ElementTree for Rust

Build Status Crates.io License rustc 1.56.0 Documentation

This library parses XML into a Python ElementTree like structure. It currently has basic support for reading and writing with pretty good namespace support and the ability to inspect the file.

It's not recommended to use this for larger documents as the entire document will be loaded into memory. However it's pretty good for working with configuration files and similar things.

Example

let root = Element::from_reader(r#"<?xml version="1.0"?>
<root xmlns="tag:myns" xmlns:foo="tag:otherns">
    <list a="1" b="2" c="3">
        <item foo:attr="foo1"/>
        <item foo:attr="foo2"/>
        <item foo:attr="foo3"/>
    </list>
</root>
"#.as_bytes()).unwrap();
let list = root.find("{tag:myns}list").unwrap();
for child in list.find_all("{tag:myns}item") {
    println!("attribute: {}", child.get_attr("{tag:otherns}attr").unwrap());
}

License and Links

Commit count: 70

cargo fmt