By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,402 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,402 IT Pros & Developers. It's quick & easy.

appending data to an xml file

P: n/a
I want to append/insert additional data to an xml file.

Context: I use gccxml to parse C header files. gccxml creates an xml
file containing all the definitions from the header files. The xml
files may be somewhat largish, for 'windows.h' it has more than 5 MB.

Since the xml does not contain #define statements, I want to run gccxml
again with the --preprocess and -dM flags, which dumps out the #define'd
symbols.

I want this information also to be in the same file, but simply
appending it to the xml smells hackish, and I don't know if the latter
xml parsing stage can get this additional data with an error handler, or
somehow else. Maybe I can find the end of the xml data myself, before
giving it to the sax parser.

Better, imo, would be to add the dumped info into a proper xml tag, and
inject it into the original file. Is that (efficiently) possible?

Thomas
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Thomas Heller wrote:
I want to append/insert additional data to an xml file. [...] Better, imo, would be to add the dumped info into a proper xml tag, and
inject it into the original file. Is that (efficiently) possible?


My technique, when I can't just strip the root element and
have a document fragment consisting of a huge list of the
other elements, is just to seek to the end of the file,
back up to the beginning of the '</xml>', and begin overwriting
the file from that point... seems to work nicely, and in
most cases since I'm the one who wrote the file in the first
place I know that I've written '</xml>\n' and can just
seek to the end minus 8 bytes (when on Windows, anyway...).

-Peter
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.