Re: modifying existing XML with SAX
paul.heil@gmail.com wrote:
I'm not sure I see how XSLT will help me. I'm not transforming the
XML. I'm trying to append a new
<ENTRY>
<TIME>timestamp</TIME>
<DATE>datestamp</DATE>
<MODULE>module data</MODULE>
<MODULE2>module data</MODULE2>
</ENTRY>
to the end of the existing XML just above the </LOGFILE>. I do this
constantly while the program is running at some user-defined interval
(typically every 30 seconds).
Personally, for something like this, I'd probably not bother with XML
parser at all. It should be easy to read backward from the end of the
file, find the offset of the line containing </LOGFILE>, write your
entry starting at this offset, and finally write </LOGFILE> line back at
the end. It does not sound particularly efficient to reread the whole
log every time you want to append an entry, with SAX or otherwise.
Is there a way to roll my own IStream implementation for
IXMLDomDocument load() and save() such that it only keeps a few KB in
memory at any given time and not the whole document?
You can have IXMLDomDocument read directly from disk file - just give it
a file:// URL. That won't help you any - IXMLDomDocument itself still
keeps the whole document in memory, not as raw data but as DOM tree.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925