Search code examples
c++xmlxerces

changing value of a tag through XML parser


I am new to XML. I want to change the value of a tag in an xml file. I am using Xerces c++ library for this purpose. Can anyone tell me how to do it ?


Solution

  • load the XML document: xmlDoc=loadXMLDoc("temp.xml");

    get the tag "tag1" you want to write (first one):DOMNode x=xmlDoc.getElementsByTagName("tag1")[0];

    get the value node: DOMNode y=x.childNodes[0];

    change the value of this node: y.nodeValue="New Value";