The sample I looked for is something like this:

...
#include <sstream>
...
char* CXMLAgent::Dom2XML(DOM_Node& toWrite)
{
        ostringstream mystream;
        DOMSerializerFormatTarget* target = new
DOMSerializerFormatTarget(mystream);
        DOMSerializer* serializer  = new DOMSerializer();
        serializer->serialize (target, toWrite);

        basic_string <char> out2 (mystream.str());
        const char *out1 = out2.c_str ();
        char *out = strdup (out1);

        delete target;
        delete serializer;

        return out;
}
...

May be the code is not very good, but its fine for me.

Jan

> -----Original Message-----
> From: Evert Haasdijk [mailto:[EMAIL PROTECTED]]
> Sent: Monday, November 26, 2001 1:43 PM
> To: [EMAIL PROTECTED]
> Subject: RE: DOMSerializer
>
>
> It's fairly straightforward, really: you can just use any ostream
> and stream
> a DOM_Node into it. For example,
>
> DOM_Node node;
> cout << node;
>
> should work. In this manner, the DOM_Node and its children are
> written using
> UTF-8. If you want to use another decoding, you must create your own
> serializer. See the code for
> std::ostream& operator<< (std::ostream& s, const DOM_Node& node)
> for an example.
>
> The errors you found are indeed errors: some mailer (probably
> mine) mangled
> the original files and inserted '3D' after '=' characters.
>
> >     "void operator=3D(const DOMSerializerFormatTarget& rhs);"
> >                  --^^--
> > (row 75)
> Should read:
>
> void operator=(const DOMSerializerFormatTarget& rhs);
>
> > and
> >
> >     "DOMSerializer(const std::string& encoding =3D defaultEncoding_);"
> >                                                 --^^--
> > (row 100)
> should read:
>
> DOMSerializer(const std::string& encoding = defaultEncoding_);
>
>
>
> > > > > I look for a short example how to use the DOMSerializer class to
> > > >serialize
> > > > > a
> > > > > DomNode into a string.
>
> Hope this helps, Evert
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to