TinyXML problem

Hi,
I am using tinyXML to process a bunch of XML files. I want to read an XML file then process it like delete some elements, change the value of some attributes and then write to a different file. I am doing something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
        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.
Last edited on
I cant't spot anything wrong with the code. This seems to be more a lib related question rather then c++. Please ask on their forums.
Topic archived. No new replies allowed.