Menu

Get the XML string

Developer
Anonymous
2003-12-04
2003-12-04
  • Anonymous

    Anonymous - 2003-12-04

    I'm using TinyXML without STL and I wanted to know if there is a way to retrieve the XML string into a variable instead of saving it into a file or using the stdout.

    What I've done is put public the TiXmlDocument::StreamOut() function instead of protected. This seems to work.

    Is there another way so I don't have to change the code?

    Thanks. And by the way, this is a great parser!
    Jonathan

     
    • Yves Berquin

      Yves Berquin - 2003-12-04

      Here is a function I'm using :

      std::string s_get_xml_string (const TiXmlNode * XNp_ptr)
      {
         std::string s;
         std::ostringstream os_stream (std::ostringstream::out);

         os_stream << * XNp_ptr;
         s = os_stream . str ();
         return s;
      }

      Yves

       
    • Anonymous

      Anonymous - 2003-12-04

      Thanks for your reply. But this only works when you use TinyXml with STL and I don't :(

      Jonathan

       
    • Nicola Civran

      Nicola Civran - 2003-12-04

      Try something like this:

          ...
          TiXmlOutStream s;
          s << *node;
          const char* p = s.c_str();
          ...

      Nicola

       
    • Anonymous

      Anonymous - 2003-12-04

      That's it! Thank you very much!

      Jonathan

       

Log in to post a comment.

MongoDB Logo MongoDB