[xml] xmlElemDumpMemory

Date view Thread view Subject view Author view

From: mskala@ansuz.sooke.bc.ca
Date: Sat Jan 20 2001 - 01:21:36 EST


If you want to write a document to a file handle, you can use xmlDocDump.
If you want to write a document to memory, you can use xmlDocDumpMemory.
If you want to write just an element (not an entire document) to a file
handle, you can use xmlElemDump.
I want to write just an element (not an entire document) to memory; I want
to use xmlElemDumpMemory. But xmlElemDumpMemory does not exist.

Could xmlElemDumpMemory be created? It looks to me, from a first look at
tree.c, like it would be really easy to do. xmlDocDumpMemory differs only
slightly from xmlDocDump, and it seems to me that the same difference
could be applied to xmlElemDump to create xmlElemDumpMemory. It's
important because as far as I can tell there is no other way to turn just
*part* of a tree into flat data in memory; if I want to do that, at the
moment I have to write an entire new XML generator of my own and traverse
the tree myself instead of letting libxml do it. I suppose another
solution would be to graft my subtree into a separate document of its own,
generate the XML for the document, and then strip out the prolog, but
that's not a great solution either.

Given that you can write documents to file handles, documents to memory,
and elements to file handles, it seems like you should be able to write
elements to memory. Furthermore, if you had to choose just one of
xmlElemDump and xmlElemDumpMemory, I think xmlElemDumpMemory is a lot more
useful anyway - because if I want to send the resulting fragment of XML to
a file, I can do that afterwards, whereas if I want to recover the data
for further processing in my program, it's practically impossible to do
that with xmlElemDump. I'd probably have to create some kind of buffered
pipe to myself to make xmlElemDump work; a really yicky solution.

Just for my own use I can easily modify my copy of libxml to provide this
function - but it would be really unpleasant if I had to distribute a
modified libxml to every user of my app.

Matthew Skala
mskala@ansuz.sooke.bc.ca :CVECAT DELENDA EST
http://www.islandnet.com/~mskala/

----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Jan 20 2001 - 02:45:11 EST