Skip to content

Parsing

XmlDeserializer turns XML input into an XmlDocument tree. It reads the XML declaration, normalizes line breaks, resolves namespaces and preserves comments.

use draviavemal_xml_rs::XmlDeserializer;
let xml = r#"<note><to>World</to></note>"#;
let document = XmlDeserializer::vec_to_xml_doc_tree(xml.as_bytes().to_vec())?;

vec_to_xml_doc_tree takes a Vec<u8>, so pass your_string.as_bytes().to_vec() for an in-memory string.

use draviavemal_xml_rs::XmlDeserializer;
let document = XmlDeserializer::file_to_xml_doc_tree("catalog.xml")?;
InputHandling
XML declarationversion and encoding are read onto the document (encoding defaults to utf-8).
NamespacesPrefix → URI mappings are resolved; QNames keep their prefix.
AttributesKept in source order.
Text & mixed contentUnescaped and stored as text nodes.
CommentsPreserved as comment nodes and re-emitted on serialize.
Self-closing tagsParsed as empty elements.