8000 GitHub - vodofrede/xmlite-rs: An XML 1.0 document parser implementation for Rust.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

vodofrede/xmlite-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xmlite

XML 1.0 parser library for Rust.

Usage

The two most relevant functions are xmlite::document and xmlite::tags for parsing a whole document or individual tags.

See the documentation for specific usage instructions.

Examples

Parse a document:

let text = r#"<?xml?><can><beans kind="fava">Cool Beans</beans><sauce></sauce></can>"#;
let xml = xmlite::document(text).unwrap();
eprintln!("{xml:?}");
assert_eq!(xml.name(), Some("can"));
assert_eq!(xml.children().next().unwrap().name(), Some("beans"));
assert_eq!(xml.children().next().unwrap().attr("kind"), Some("\"fava\""));

Mutate the document afterwards:

let text = r#"<?xml?><bag><pastry kind="danish" /></bag>"#;
let mut xml = xmlite::document(text).unwrap();
let attr = xml.children_mut().find(|e| e.name() == Some("pastry")).unwrap().attr_mut("kind");
*attr.unwrap() = "berliner".to_owned();

License

This project is licensed under the AGPL. See the license text for more information.

References

https://www.w3.org/TR/REC-xml/
https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home

About

An XML 1.0 document parser implementation for Rust.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

0