Adding text to tinyxml2

I am trying to create an XML file using TinyXML2. Although there are many examples and download guides, there seems to be very little cost savings. I basically want to end up with:

<node>text</node> 

I know that I can get the "node" parts by adding elment, but how to set the text part? The item has a "GetText", but I cannot find a "SetText". There is also an XMLText class, but it has no methods for setting text!

+4
source share
1 answer

I built with g ++ 4.2.1 on OS X 10.6 and it works fine. The output signal is <Version>1.0.0</Version> .

 #include "tinyxml2.h" using namespace tinyxml2; int main(int argc, char* argv[]) { tinyxml2::XMLDocument doc; tinyxml2::XMLElement* versionNode = doc.NewElement("Version"); tinyxml2::XMLText* versionText = doc.NewText("1.0.0"); versionNode->InsertEndChild(versionText); doc.InsertEndChild(versionNode); XMLPrinter printer; doc.Print(); return 0; } 
+6
source

Source: https://habr.com/ru/post/1443550/


All Articles