use xml_doc::{Document, Element, Node}; #[test] fn test_escape() { let expected = r#" ><&"'text "#; let mut doc = Document::new(); let container = doc.container(); let root = Element::build(&mut doc, "root") .attribute("attr", "><&\"'attrval") .push_to(container); Element::build(&mut doc, "inner") .namespace_decl("ns", "><&\"'nsval") .text_content("><&\"'text") .push_to(root); doc.push_root_node(Node::Comment("<&".to_string())) .unwrap(); doc.push_root_node(Node::CData("<&".to_string())) .unwrap(); doc.push_root_node(Node::DocType("<&".to_string())) .unwrap(); doc.push_root_node(Node::PI("<&".to_string())).unwrap(); let xml = doc.write_str().unwrap(); assert_eq!(xml, expected); }