Created
March 24, 2011 11:22
-
-
Save poochin/884912 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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