[xsd-users] XML Object to String/Text
boris at codesynthesis.com
Wed Feb 21 10:10:49 EST 2007
Paddy Vishnubhatt <Paddy.Vishnubhatt at 3leafnetworks.com> writes:
> 1. is there a simple way to get a stringified representation of the
> object? Like in the Java API (xmlbeans), xmlText() or even toString()
> which outputs a Sring representation of the given Xml Object?
You can use one of the serialization functions together with
std::ostringstream. For instance, in the library example there is
the this line:
// Write it out.
catalog_ (std::cout, *c, map);
You can replace it with something like this (also add #include <sstream>):
// Write it to string.
catalog_ (ostr, *c, map);
std::string str = ostr.str (); // XML is in str.
> 2. I see that there are documented ways to create DOMDocument from which
> one can use DOMWriter to use writeString to get to ultimately get to
> the string - is there an example/sample code that I can use for/as
There is some sample DOM manipulation code on the Wiki, see for example
3.1 and 3.2:
The ostringstream way is much easier though.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20070221/ed540e46/attachment.pgp
More information about the xsd-users