use xml_doc_log4rs::{Document, Element, Node}; #[test] fn test_escape() { //log4rs::init_file("log4rs_config.yaml", Default::default()).unwrap(); 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); }