Create an XML Document Dynamically (C-C++)
We have already demonstrated how to create an XML DOM object from an existing XML data file. In this section, we will show you how to create an XML document dynamically in an application. Specifically, we will demonstrate how to add processing instructions, comments, elements, and text nodes. We will also show how to use extra white space text nodes to provide a structured format when the DOM object is serialized. Such tasks are useful for creating an XML document that is also easy for humans to read.
This tutorial uses or creates the following files:
|Source: dynamDOM.cpp||Creates an XML document dynamically.|
|Output||When you build and run the dynamDOM project, you should get this output in a console window.|
- Create a Win32 console application in Visual C++. For detailed instructions on how to do this, see Set Up My Visual C++ Project. Name the project dynamDOMProj.
Next, we'll add the source code for the dynamDOM project.