Re: [xml] Parsing from a compressed string



Daniel Veillard wrote:
On Sun, Jul 13, 2008 at 07:44:12AM +0200, Stefan Behnel wrote:
Hi,

it seems that libxml2 can parse zlib compressed data from files. What
would be
the right way to parse compressed data from a string in memory? And,
yes, I
want to avoid unpacking it before I parse it.

  The simplest I can see is use
   http://xmlsoft.org/html/libxml-parser.html#xmlReadIO
and providing ioread/ioclose/ioctxt to be compressed read/close and
buffer arguments.

Same question for serialisation? Is there anything like a compressing
OutputBuffer?

  No but similary you can use xmlSaveToIO
   http://xmlsoft.org/html/libxml-xmlsave.html#xmlSaveToIO
with a compressed write and close.

  The harder is probably to debug the provided compressed handlers around
the edge cases, but it really shoudl not be much code if using existing
compression APIs.

Thanks, that's what I thought, too. It would be nice if libxml2 provided
an API function that just set everything up correctly. Because these
things tend to get pretty hairy when you get into the details.

I was hoping that someone would post some existing code, but since there
were no other responses so far...

Stefan




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