xml_Utils.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:warriorframework 作者: warriorframework 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号