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;
IXMLDOMDocument 2Ptr pXMLDoc;
IXMLDOMNodePtr pNode;
IXMLDOMProcessi ngInstructionPt r pi;
hr = pXMLDoc.CreateI nstance("Msxml2 .DOMDocument.4. 0");
pi = pXMLDoc->createProcessi ngInstruction(" xml", "version=\"1.0\ "");
pXMLDoc->appendChild(pi );
pNode = pXMLDoc->createNode("1" , "root", "");
pXMLDoc->appendChild(pN ode);
pNode = pXMLDoc->createNode("1" , "element1", "");
pXMLDoc->documentElemen t->appendChild(pN ode);
------------------------------------------------------
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;
IXMLDOMDocument 2Ptr pXMLDoc;
IXMLDOMNodePtr pNode;
IXMLDOMProcessi ngInstructionPt r pi;
hr = pXMLDoc.CreateI nstance("Msxml2 .DOMDocument.4. 0");
pi = pXMLDoc->createProcessi ngInstruction(" xml", "version=\"1.0\ "");
pXMLDoc->appendChild(pi );
pNode = pXMLDoc->createNode("1" , "root", "");
pXMLDoc->appendChild(pN ode);
pNode = pXMLDoc->createNode("1" , "element1", "");
pXMLDoc->documentElemen t->appendChild(pN ode);
------------------------------------------------------
Comment