Skip to content

Instantly share code, notes, and snippets.

@rikwatson
Created April 1, 2019 12:44
Show Gist options
  • Save rikwatson/00bbe7f2cb34d1a61bbb89a3bc6146e0 to your computer and use it in GitHub Desktop.
Save rikwatson/00bbe7f2cb34d1a61bbb89a3bc6146e0 to your computer and use it in GitHub Desktop.
Basic XML DOM parsing
from xml.dom.minidom import parse
dom = parse("foo.xml") # or dom = parseString( "<myxml>Some data <empty/> some more data</myxml>" )
for node in dom.getElementsByTagName('bar'): # visit every node <bar />
print node.toxml()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment