Avatar of PhilC
PhilC

asked on 

tinyxml insert block of xml (c++)

I know how to build an xml document with tinyxml such as

TiXmlElement root=TiXmlElement("root");
TiXmlElement *new_element = new TiXmlElement("element");
new_element->LinkEndChild(new TiXmlText("test"));
root.LinkEndChild(new_element);

but what I do not know how to do is:
if I already the text <element>another element here</element>
build a new document so that this text is inserted into the root

I thought I could do something like this, but it errors out
TiXmlDocument sub_element; sub_element.Parse(xml_string);
root.LinkEndChild(sub_element.ToElement());
C++XML

Avatar of undefined
Last Comment
PhilC

8/22/2022 - Mon