Skip to content

Instantly share code, notes, and snippets.

@poochin
Created March 24, 2011 11:22
Show Gist options
  • Select an option

  • Save poochin/884912 to your computer and use it in GitHub Desktop.

Select an option

Save poochin/884912 to your computer and use it in GitHub Desktop.
from xml.dom.minidom import NodeList
def getChildsByTagName(dom, tagName, **attrs):
'''return NodeList of tagName[attrs] from dom'''
nl = NodeList()
for node in dom.childNodes:
if hasattr(node, 'tagName') and node.tagName == tagName:
for k, v in attrs.iteritems():
if node.getAttribute(k) != v:
break
else:
nl.append(node)
return nl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment