TiXmlElement *pElement;
TiXmlNode *newNode=0;
newNode = sourceXMLNode->Clone();
pElement = newNode->ToElement();
TiXmlAttribute* pAttrib=pElement->FirstAttribute();
while (pAttrib)
{
if(StringToUpper(pAttrib->Name())=="MY_ATTRIBUTE")
{
pAttrib->SetValue("H0");
}
pAttrib=pAttrib->Next();
}
destXMLNode->LinkEndChild(pElement);
So here I am making a copy of sourceXMLNode and then search for
attribute named MY_ATTRIBUTE and then change its value. And then add
this copied node to destXMLNode. But in the end when I write the
destXMLNode to a file it doesn't show the changed value, it shows the
old value that was present in sourceXML.
But if I don't make a clone and just use sourceXMLNode pick the
element from it and change he attribute value and then write the
sourceXMLNode I see the changed value.
Why does making a clone not change the value in destXMLNode??
Does anybody have any idea why that might be happenning. Any help or
suggestions would be greatly appreciated.