0

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

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

I selected the required node in which the attribute has to be set using selectSingleNode function. After selecting the required node, I tried to set attribute.

But the PElement pointer does not shift to the required node. It stayed on the root node. Result: added the attribute in root itself.

Is there any way, I can shift my PElement to the node resulted in selectSingleNode function? So that I can set the attribute.

gnat
  • 6,213
  • 108
  • 53
  • 73
Rajakumar
  • 442
  • 1
  • 9
  • 21

2 Answers2

1

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
  • 7,092
  • 3
  • 36
  • 50
1

I think you just use the funcion get_documentElement, then you will get the root node in the DOM, the root pointer is stored in the pElement, and you call the setAttribute function by using the pointer pElement,so the attribute of root will always be set

GDP
  • 8,109
  • 6
  • 45
  • 82
KevinSun
  • 11
  • 1