how to save a modified .xml back

Hyunchul Kim hyunchul.mailing at gmail.com
Fri Dec 25 22:02:15 EST 2009


Hi all,

I want to load a small .xml file, modifiy some nodes and save the .xml with
modifications to another .xml file.

I managed to load and modify a small .xml file using xml.dom.minidom and
xml.dom.pulldom.

However, I don't know how to save it back using any of two modules.

Any suggestion?

Thank you in advance,

**********
from xml.dom.pulldom import START_ELEMENT, parse
doc = parse('input.xml')
for event, node in doc:
    if event == START_ELEMENT and node.localName == "something_interesting":
        doc.expandNode(node)
        for an_element in node.childNodes:
            do_something()
*********

Hyunchul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091226/b68dc20b/attachment.html>


More information about the Python-list mailing list