def verifyParentandChildrenMatch (datafile, pnode, cnode, cvalue, rnode, rvalue):
"""
Searches XML file for the parent node. Finds the 1st child node and checks its value
if value is a match, then search for second child and check if its value matches
datafile = xml file searched
pnode = parent node
cnode = child node
cvalue = child node value
rnode = reference node
rvalue = refernce node value
"""
tree = ElementTree.parse(datafile)
root = tree.getroot()
status = False
for node in root.findall(pnode):
value = node.find(cnode).text
if value == cvalue:
if node.find(rnode) is not None:
cnodev = node.find(rnode).text
# print_debug("-D- cnodev: '%s', rvalue : '%s'" % (cnodev, rvalue))
if cnodev == rvalue:
# print_debug("-D- BREAK END METHOD verifyParentandChildrenMatch_Status '%s'" % status)
return True
return status
评论列表
文章目录