Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TinyXML: Save document to char * or string

Tags:

c++

tinyxml

I'm attempting to use TinyXML to read and save from memory, instead of only reading and saving files to disk.

It seems that the documnent's parse function can load a char *. But then I need to save the document to a char * when I'm done with it. Does anyone know about this?

Edit: The printing & streaming functions aren't what I'm looking for. They output in a viewable format, I need the actual xml content.

Edit: Printing is cool.

like image 334
foobar Avatar asked Sep 21 '08 06:09

foobar


1 Answers

Here's some sample code I am using, adapted from the TiXMLPrinter documentation:

TiXmlDocument doc;
// populate document here ...

TiXmlPrinter printer;
printer.SetIndent( "    " );

doc.Accept( &printer );
std::string xmltext = printer.CStr();
like image 66
Alex B Avatar answered Oct 14 '22 19:10

Alex B