MemBufFormatTarget to iostream?

View: New views
4 Messages — Rating Filter:   Alert me  

MemBufFormatTarget to iostream?

by Daniel Burrell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey I have a DOMDocument,
What's the best way to get it's xml (human readable) data into an iostream
object, ready for whatever I want to do with it?

Re: MemBufFormatTarget to iostream?

by Sebastian 'CrashandDie' Lauwers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Sep 15, 2008 at 2:30 AM, Daniel Burrell
<daniel.burrell@...> wrote:
> Hey I have a DOMDocument,
> What's the best way to get it's xml (human readable) data into an iostream
> object, ready for whatever I want to do with it?

Something along these lines (from memory, early morning, might be some errors)

DOMDocument * doc = NULL;

//snip, say you create your document, bla bla

DOMImplementation * impl =
DOMImplementationRegistry::getDOMImplementation (X ("Core"));
DOMWriter * theSerializer = impl->createDOMWriter ();
XMLFormatTarget * formTarget = new MemBufFormatTarget;

theSerializer->writeNode(formTarget, *doc);
std::string xmlString = (char *) ((MemBufFormatTarget *)
formTarget)->getRawBuffer ();

From the char*, it's easy to put it into an iostream. Now this of
course is for a one time.

HTH

--
question = ( to ) ? be : ! be;
      -- Wm. Shakespeare

Re: UTF-8 versus UTF-16

by David.Sander :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello

i  have a question to UTF. I have an xml file which is validated against a
schema file. My Problem is, that if i write ufrt-16 in the xml file i get
an error, but no by utf-16.

Can there an error in my schemafile or can't handle xerces utf-16 which i
didn't believe.



Thanks david

Re: UTF-8 versus UTF-16

by David.Sander :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ok, i found the error,

The xmlfile encoding wasn't set to utf-16, so ich changed it to unicode
and the problem was solved.

Thanks


David.Sander@... schrieb am 15.09.2008 14:31:56:

> Hello
>
> i  have a question to UTF. I have an xml file which is validated against
a
> schema file. My Problem is, that if i write ufrt-16 in the xml file i
get
> an error, but no by utf-16.
>
> Can there an error in my schemafile or can't handle xerces utf-16 which
i
> didn't believe.
>
>
>
> Thanks david
LightInTheBox - Buy quality products at wholesale price!