1

Actually, i have a c++ code which decode a xml from a xml file with TinyXML library.

std::string = "xmlFile.xml";

TiXmlDocument doc(xml_name);

bool loadOkay = doc.LoadFile();

if (loadOkay){...} 

Where xmlFile.xml

<?xml version="1.0">

<body>

    ....

</body> 

Now I need to decode the same xml, but now I have the xml contents atfunction input.

I have thought it would be something like:

std::string contents = "<?xml version="1.0">    <body> ... </body>";

TiXmlDocument doc(contents);

bool loadOkay = doc.LoadFile();

if (loadOkay){...}

But obviously, this not work so.

How can I solve this?

  • Try the Parse() method. Also http://stackoverflow.com/questions/2862892/can-tinyxml-load-xml-from-string-instead-of-file/2863183#2863183 – halfwaythru Jun 19 '13 at 22:05

1 Answers1

0

Try the TiXmlDocument::Parse() method instead of the LoadFile() method. Also take a look at this question.

Can TinyXml load Xml from string instead of file?

Community
  • 1
  • 1
halfwaythru
  • 177
  • 3
  • 12