In my current project I have to modify several XML documents using tinyXML.
I didn't find a function SetText(const char*). I know that instead you have to create the TiXmlText and link it to the Element:
TiXmlElement* pParent = ...;
TiXmlText* pText = new TiXmlText(szText);
pParent->LinkEndChild(pText);
However, if the node already has a Text child, according to my understanding I have to modify its value instead.
I also did not find something like FirstChildText() or GetTextNode() etc. I guess using this line
TiXmlText* pText = pParent->FirstChild()->ToText();
will cause problems if pParent already has other children than text (in my case an attribute, comment - I can ignore elements/mixed mode), so I ended up in iterating over all children checking their Type() to be TINYXML_TEXT.
Is there a better way to do so or maybe an existing set of helper functions (including setText) I didn't find yet?