xml_Utils.py 文件源码

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

项目:warriorframework 作者: warriorframework 项目源码 文件源码
def getChildAttributebyParentTag (datafile, pnode, cnode, cattrib):
    """Find the attribute in child node by traversing through the parent node
    in the given file
    datafile = xml file searched
    pnode = parent node
    cnode = child node
    cattrob = child node attrib
    """
    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.get(cattrib)
            return value
        else:
            # print_info("could not find cnode under the given pnode")
            return False
    else:
        # print_info("could not find pnode in the provided file")
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号