Skip to main content

parse

Function parse 

Source
pub fn parse(src: &str) -> Result<Value, XmlError>
Expand description

Parse an XML document with the shared default parser.

The engine is built once, on first use, and reused after that; reuse is safe because Tabnas::parse takes &self and builds a fresh parse context per call, and Tabnas is Send + Sync. Use make or make_with when the parser needs configuring.

let value = tabnas_xml::parse("<a>Tom &amp; Jerry</a>")?;
assert_eq!(
    value.to_string(),
    r#"{"name":"a","localName":"a","attributes":{},"children":["Tom & Jerry"]}"#
);
assert_eq!(tabnas_xml::parse("<a/>junk").unwrap_err().code, "text_at_top_level");