Create an XML Document Dynamically (C/C++)

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - DOM Developer's Guide

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 of creates the following files:

Component Description
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.

To create the dynamDOM project in Visual C++

  • 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.