pub fn xml_to_json(xml: &str) -> Result<String, Box<dyn Error>>Expand description
Converts an XML document to a JSON representation.
Attributes become @name keys, text becomes #text, and repeated
sibling elements become arrays. The output has exactly one top-level key:
the root element name.
§Errors
Returns an error if the XML is malformed or empty.
§Examples
use sheeter_engine::xml_to_json;
let json = xml_to_json("<r><a>1</a><a>2</a></r>").unwrap();
assert_eq!(json, r#"{"r":{"a":["1","2"]}}"#);