views:

334

answers:

1

I try to set an attribute in a XML node using MSXML. IXMLDOMElement alone has the member function setatrribute. So i got the document element.

pXMLDocumentElement -> get_documentElement (& pElement );
pElement -> selectSingleNode ( nodePathString ,& pNode );
.
.
.
pElement -> setAttribute ( bstr , var );

I selected the required node inwhich the attribute has to be set using selectsinglenode funcion. after selecting the required node, i tried to set attribute.

But the PElement pointer doesnot shift to the required node. it stayed on the root node. Result: added the attribute in root itself

Is ther any way, I can shift my PElement to the node resulted in selectsinglenode function. so that i can set the attribute,.

+1  A: 

I think you have to use the setAttributeNode API on your pNode pointer.

While you are at it read this tutorial on using MSXML. And after you have the basics covered this blog.

Abhay