appending data to an xml file

Thomas Heller theller at python.net
Tue Jan 11 15:05:03 EST 2005


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



More information about the Python-list mailing list