use std::fmt::Write as _;
fn main() {
let source = "<?xml version=\"1.0\"?>
<catalogue>
<book lang='en'><![CDATA[Dune & Children]]></book>
<!-- prices exclude shipping -->
</catalogue>";
let doc = oxml::parse(source).expect("the document is well-formed");
let once = doc.to_xml();
println!("once:\n{once}\n");
let twice = oxml::parse(&once).expect("output parses").to_xml();
assert_eq!(once, twice, "serialisation should be a fixed point");
println!("serialising again changed nothing\n");
let mut buffer = String::new();
doc.write_xml(&mut buffer)
.expect("writing to a String cannot fail");
assert_eq!(buffer, once);
let mut report = String::new();
let _ =
writeln!(report, "{} nodes, {} bytes of XML", doc.len(), once.len());
print!("{report}");
}