Reputation: 11
I am trying to parse xml from a message like this:
char * data = message.c_str ();
How can I create the xmlDoc with the string or a char array data, meaning without the xml file?
Upvotes: 1
Views: 1715
Reputation: 2080
You could use the std::istream& operator >> (std::istream& in, TiXmlNode& base);
function defined in tinyxml.h
:
C++ style input:
based on
std::istream operator>>
Reads XML from a stream, making it useful for network transmission. The tricky part is knowing when the XML document is complete, since there will almost certainly be other data in the stream. TinyXML will assume the XML data is complete after it reads the root element. Put another way, documents that are ill-constructed with more than one root element will not read correctly. Also note that operator>> is somewhat slower than Parse, due to both implementation of the STL and limitations of TinyXML.
Upvotes: 2