use xml_dom::level2::convert::*;
use xml_dom::level2::*;
#[allow(unused_must_use)]
fn main() {
let implementation = get_implementation();
let document_type = implementation
.create_document_type(
"html",
Some("-//W3C//DTD XHTML 1.0 Transitional//EN"),
Some("http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"),
)
.unwrap();
let mut document_node = implementation
.create_document(
Some("http://www.w3.org/1999/xhtml"),
Some("html"),
Some(document_type),
)
.unwrap();
let document = as_document_mut(&mut document_node).unwrap();
let mut root_node = document.document_element().unwrap();
let root = as_element_mut(&mut root_node).unwrap();
root.set_attribute("lang", "en");
let _head = root.append_child(document.create_element("head").unwrap());
let _body = root.append_child(document.create_element("body").unwrap());
let xml = document_node.to_string();
println!("{}", xml);
assert!(xml.starts_with("<!DOCTYPE html "));
assert!(xml.contains("<html lang=\"en\">"));
assert!(xml.contains("<head></head>"));
assert!(xml.contains("<body></body>"));
assert!(xml.ends_with("</html>"));
}