Using TinyXML on top of a byte stream instead of a file

Is it possible to use TinyXML on top of a byte stream instead of a file?

Consider this piece of code:

TiXmlDocument doc("abc.xml");
if (!doc.LoadFile())
 return;
TiXmlHandle hDoc(&doc);

The above code snippet accepts the file as input. How can I change the code so that it accepts a stream of bytes? The sample code snippet will be great!

+3
source share
2 answers

Directly call TinyXmlDocument::Parsewith the completed byte stream NULLas the first argument. (See Implementation TinyXmlDocument::LoadFileon how to call this function).

+3
source

TinyXML STL → , TiXmlNode:

std::istream& operator>> (std::istream & in, TiXmlNode & base)  

:

std::istream & stream = /*your stream here*/;
TiXmlDocument xmlDoc;
stream >> xmlDoc;

TinyXML :

TinyXML STL. STL TinyXML std::string std:: istream, std:: ostream, operator < < operator → . (...) : TIXML_USE_STL

+1

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


All Articles