You need to create each XMLNode instance with the XMLDocument instance. You can write the content by providing an OutputStream object to XMLDocument.write method.
:::java
XMLDocument document = new XMLDocument();
XMLNode root = new XMLNode("root", document);
root.setAttribute("id", 123);
document.setRoot(root);
XMLNode child = new XMLNode("child", document);
child.setTextContent("Node content");
root.addChild(child);
document.write(new FileOutputStream(new File("output.xml")));