daemon: Minor XML-related cleanup.

This commit is contained in:
tgoff0 2015-02-27 00:06:47 +00:00
parent 1cda303b22
commit 750b6c507d

View file

@ -135,10 +135,19 @@ def getoneelement(dom, name):
return None return None
return e[0] return e[0]
def iterChildren(dom, nodeType):
'''\
Iterate over all child elements of the given type.
'''
for child in dom.childNodes:
if child.nodeType == nodeType:
yield child
def gettextchild(dom): def gettextchild(dom):
# this could be improved to skip XML comments '''\
child = dom.firstChild Return the text node of the given element.
if child is not None and child.nodeType == Node.TEXT_NODE: '''
for child in iterChildren(dom, Node.TEXT_NODE):
return str(child.nodeValue) return str(child.nodeValue)
return None return None