facet-xml-node
Raw XML node types—represent arbitrary XML without a schema.
Overview
This crate provides generic XML types (Element, Content) that can represent
any XML document without needing predefined Rust structs. It's useful when you
need to parse XML dynamically or work with XML of unknown structure.
Types
Element
Captures any XML element with its tag name, attributes, and children:
use Element;
let xml = r#"<item id="42" status="active">Hello <b>world</b></item>"#;
let element: Element = from_str?;
assert_eq!;
assert_eq!;
Content
Represents either text or a child element:
use ;
for child in &element.children
Use Cases
- Parsing XML of unknown or variable structure
- Building XML transformers or validators
- Bridging between typed and untyped XML representations
- Testing and debugging XML serialization
Comparison
| Approach | Use Case |
|---|---|
Typed structs with #[derive(Facet)] |
Known XML schema, compile-time safety |
facet-xml-node::Element |
Unknown/dynamic XML, runtime flexibility |
Sponsors
Thanks to all individual sponsors:
...along with corporate sponsors:
...without whom this work could not exist.
Special thanks
The facet logo was drawn by Misiasart.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.