p***@gmail.com
2006-04-24 20:34:46 UTC
I'm working on a c++ application that writes its output as XML, I
currently have it running using DOM (IXMLDOMDocument), but the load()
and save() calls can take a LONG time when the document gets to be more
than a meg or two. That and the fact that the entire document has to be
loaded in to memory makes this really bad for my pocket-pc application.
After some searching I found that SAX was probably my answer. Just load
a document with an IStream and modify it with SAX. Unfortunately, I
haven't found much in the way of examples of how to do that exactly.
Has anybody got a C++ example of how to modify an existing XML
document(see below for an example) with SAX but not using the DOM
load() and save() commands?
Thanks,
PaulH
Here is an example of the XML I'm working with. I would just want to
append a new "ENTRY" element and all sub-elements each time.
<?xml version="1.0" encoding="UTF-8"?>
<LOGFILE>
<ENTRY>
<TIME>timestamp</TIME>
<DATE>datestamp</DATE>
<MODULE>module data</MODULE>
<MODULE2>module data</MODULE2>
</ENTRY>
<ENTRY>
<TIME>timestamp</TIME>
<DATE>datestamp</DATE>
<MODULE>module data</MODULE>
<MODULE2>module data</MODULE2>
</ENTRY>
</LOGFILE>
currently have it running using DOM (IXMLDOMDocument), but the load()
and save() calls can take a LONG time when the document gets to be more
than a meg or two. That and the fact that the entire document has to be
loaded in to memory makes this really bad for my pocket-pc application.
After some searching I found that SAX was probably my answer. Just load
a document with an IStream and modify it with SAX. Unfortunately, I
haven't found much in the way of examples of how to do that exactly.
Has anybody got a C++ example of how to modify an existing XML
document(see below for an example) with SAX but not using the DOM
load() and save() commands?
Thanks,
PaulH
Here is an example of the XML I'm working with. I would just want to
append a new "ENTRY" element and all sub-elements each time.
<?xml version="1.0" encoding="UTF-8"?>
<LOGFILE>
<ENTRY>
<TIME>timestamp</TIME>
<DATE>datestamp</DATE>
<MODULE>module data</MODULE>
<MODULE2>module data</MODULE2>
</ENTRY>
<ENTRY>
<TIME>timestamp</TIME>
<DATE>datestamp</DATE>
<MODULE>module data</MODULE>
<MODULE2>module data</MODULE2>
</ENTRY>
</LOGFILE>