Skip to content

Instantly share code, notes, and snippets.

@akyoto
Created June 29, 2012 16:37
Show Gist options
  • Select an option

  • Save akyoto/3019059 to your computer and use it in GitHub Desktop.

Select an option

Save akyoto/3019059 to your computer and use it in GitHub Desktop.
def findNodes(node, nodeName):
callList = []
if node.nodeType == Node.ELEMENT_NODE and node.tagName == nodeName:
callList.append(node)
# TODO: Improve performance, make an iterative algorithm out of this:
for child in node.childNodes:
callList += findNodes(child, nodeName)
return callList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment