Example 3: Adding elements and serializing the DOM in C++.
// Create the LastName element node
DOMElement* elem = doc->createElement( "LastName" );
// Create the textual content for the element
DOMText* text = doc->createTextNode( "Bruno" );
// Make the text node a child of the element node
elem->appendChild( text );
// Make the new element a child of the root node "Customer"
rootElem->appendChild( elem );
// Get a writer object to serialize to disk
DOMWriter* serializer = dom->createDOMWriter();
// Set the file name
XMLFormatTarget* target
= new LocalFileFormatTarget( "c:\\mydocument.xml" );
// Write the XML to the file
serializer->writeNode(target, *doc);