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 ...

Get XML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.