[xml] Proper usage of xmlSaveToBuffer



Hi,

I'm having a little trouble using xmlSaveToBuffer. What I want is to dump a document to an in-memory xmlBuffer, like this:

  xmlBufferPtr buf = xmlBufferCreate();
xmlSaveCtxtPtr saveCtxt = xmlSaveToBuffer(buf, m_encoding, XML_SAVE_FORMAT | XML_SAVE_NO_EMPTY);
  xmlSaveDoc(saveCtxt, doc);

However, buf remains empty. Stepping through the code shows that xmlSaveToBuffer creates an xmlOutputBufer via xmlOutputBufferCreate, which in turn uses xmlOutputBufferCreateIO with the passed xmlBuffer as context. However, when the actual xmlOutputBuffer is created, it seems to create its own xmlBuffer (in xmlAllocOutputBufferInternal), which is used for subsequent write calls.

Probably I misunderstood something. Can someone tell me what I'm doing wrong here?

Kind Regards,
  Alex

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]