Saving Documents Persistently
One way to edit an XML document is as a flat file. If an application is just making a few edits to specific element types, this is probably the best way to go. However, if you want to make edits to different element types with numerous additions to both text and the document tree—and if you also want to ensure validity—using DOM and editing the DOM tree is definitely the way to go.
If you are using DOM to edit XML files, you need a way to write the new tree back into a flat XML file again when you have finished the edit. The best way to do this is with a recursive function. The following listing is provided for your convenience. It is a function taken from a Visual Basic 6 application, but the code is readily transferable ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access