Python Parse XML Document

Examples

python_logo2

Parsing an XML document in Python is easy. Below is a simple example that loads an XML document from a file, parses and prints:

from xml.dom import minidom
dom = minidom.parse('test.xml')
print dom.toxml()

For more information, see the Python minidom documentation.

1 Comment

1 Comment

  1. Angela Jones  •  Mar 6, 2010 @18:33

    Cool Thanks for this post. I am a newbie at python and this was a big help.

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>