I am loading some data from an XML document, modifying it, and writing back out to XML. The reading is done using a SAX parser library and the writing is done with a piece of custom code. Sometimes, the file is modified externally, and extra elements are added (such as references to stylesheets). Rather than losing these extra elements when I load and save the file, I would like to pass through any unknown tags so that they appear
当未知元素与已解释元素分离时,将未知元素和属性保存为字符串并在之后输出应该很直观,但当它们交错和嵌套在已解释元素内时,情况就不那么明显了。
Can anybody suggest a succinct way to do this? Would it be simpler to switch to a DOM parser? Performance is not an issue.
NB. I am working in C++ with the Gnome Glib::Markup::Parser, but would prefer language/library agnostic answers.