Listing 2: Code for creating XML in Figure 2

WXMLStackDocument Doc();  // Unicode version  

Doc.pushProcessingInstruction(L"xml") =
 L"version='1.0' encoding='UTF-16'";  
Doc.pop();  // pops the processing instruction  

Doc.pushElement(L"Book");  
Doc.top().createAttribute(L"Status") = L"BackOrdered";  

Doc.pushElement(L"Title") = L"Doing It - Sail Around the World";  
Doc.pop();  // pops <Title>  

Doc.pushElement(L"PubId") = 736;  
Doc.pop();  // pops <PubId>  

Doc.pushElement(L"Price").createAttribute(L"Currency") = L"USD";  
Doc.top().setValue(19.99, 2);  // Assign 19.99 to <Price>  
Doc.pop();  // pops <Price>  

Doc.pushElement(L"Author");  
Doc.pushElement(L"LastName") = L"Ference";  
Doc.pop();  // pops <LastName>  

Doc.pushElement(L"FirstName").setValue(L"Jeff");  
Doc.popAll(); // Pops off all remaining nodes