9 releases

new 0.0.8 May 2, 2021
0.0.7 Feb 7, 2021
0.0.6 Jan 24, 2021
0.0.5 Dec 12, 2020
0.0.0 May 28, 2020

#235 in Parser implementations

Download history 1/week @ 2021-01-12 13/week @ 2021-01-19 9/week @ 2021-01-26 18/week @ 2021-02-02 12/week @ 2021-02-09 69/week @ 2021-02-16 3/week @ 2021-03-02 1/week @ 2021-03-09 16/week @ 2021-03-23 16/week @ 2021-03-30 9/week @ 2021-04-06 14/week @ 2021-04-13 17/week @ 2021-04-20 16/week @ 2021-04-27

59 downloads per month

MIT/Apache

195KB
5.5K SLoC

exile

Current version: 0.0.8

build

exile is a Rust library for reading and writing XML.

The goal, at least initially, is to provide an abstract syntax tree of an XML file. As such, this is a Exile is a dom parser and loads the complete contents of the document into memory.

Currently supported:

  • Attributes
  • CDATA Sections
  • Comment Parsing
  • Elements
  • Processing Instructions
  • Text Nodes
  • UTF-8
  • Whitespace Normalization

Not Supported:

  • Doctypes
  • Entities
  • Entity References
  • Other Encodings
  • Whitesace Preservation: All text nodes are treated as if whitespace collapse were in-effect.

Example

Parsing XML looks like this.

let xml = r#"
<root>
  <thing name="foo"/>
  <thing>bar</thing>
</root>
"#;

let doc = exile::parse(xml).unwrap();
for child in doc.root().children() {
    println!("element name: {}", child.name());
    if let Some(attribute) = child.attribute("name") {
        println!("name attribute: {}", attribute);
    }
}

Authoring XML looks like this.

use exile::{Document, Element, Node};
let mut root = Element::from_name("my_root");
root.add_attribute("foo", "bar");
let mut child = Element::from_name("my_child");
child.add_text("Hello World!");
root.add_child(child);
let doc = Document::from_root(root);
println!("{}", doc.to_string());

The above program prints:

<my_root foo="bar">
  <my_child>Hello World!</my_child>
</my_root>

No runtime deps

~0–355KB