Finding the Direct Children of a Node : XML Children Node « XML « Python
- Python
- XML
- XML Children Node
Finding the Direct Children of a Node
def randomChildElement(self, node):
choices = [e for e in node.childNodes
if e.nodeType == e.ELEMENT_NODE]
chosen = random.choice(choices)
return chosen
Related examples in the same category