def getChildTextbyParentTag (datafile, pnode, cnode):
"""
Seraches XML file for the first parent. Finds the child node and returns its text
datafile = xml file searched
pnode = parent node
cnode = child node
"""
value = False
tree = ElementTree.parse(datafile)
root = tree.getroot()
node = root.find(pnode)
if node is not None:
child = node.find(cnode)
if child is not None:
value = child.text
return value
else:
# print_info("could not find cnode under the given pnode")
return value
else:
# print_info("could not find pnode in the provided file")
return value
评论列表
文章目录