generate xml at runtime

Zombie (archive)

Usenet Archive
Joined
Aug 13, 2004
Messages
11
Reaction score
0
hello,
I am generating an XML document at run time.
I have been able to create the root element and the elements below it but I am not able to add attributes to elements. Can anyone please send a snippet on how to do this?

Thanks.

The sample code I am using is:

HRESULT hr;
IXMLDOMDocument2Ptr pXMLDoc;
IXMLDOMNodePtr pNode;
IXMLDOMProcessingInstructionPtr pi;

hr = pXMLDoc.CreateInstance("Msxml2.DOMDocument.4.0");
pi = pXMLDoc->createProcessingInstruction("xml", "version=\"1.0\""); pXMLDoc->appendChild(pi);

pNode = pXMLDoc->createNode("1", "root", "");
pXMLDoc->appendChild(pNode);

pNode = pXMLDoc->createNode("1", "element1", "");
pXMLDoc->documentElement->appendChild(pNode);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,802
Members
249,594
Latest member
henrywalsh

Latest Threads

Top