daemon: Minor XML-related cleanup.
This commit is contained in:
parent
1cda303b22
commit
750b6c507d
1 changed files with 14 additions and 5 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue