Crate xmltree

source ·
Expand description

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());

Structs§

  • Represents an XML element.
  • Emitter configuration structure.
  • Namespace is a map from prefixes to namespace URIs.
  • Parser configuration structure. There are more config methods than public fileds — see methods below.

Enums§

  • An error which may be returned by XmlWriter when writing XML events.
  • Errors that can occur parsing XML

Traits§

Type Aliases§