Read xml file specified content

def read_xml(path, tag_name='QW', attribute_name='value'):
    dom_tree = xml_parse(path)
    root_node = dom_tree.documentElement
    tag_list = root_node.getElementsByTagName(tag_name)
    details = ''
    for tag in tag_list:
        if tag.hasAttribute(attribute_name):
            details += tag.getAttribute(attribute_name)
    return details

Released nine original articles · won praise 2 · Views 314

Guess you like

Origin blog.csdn.net/Z_Pythagoras/article/details/105060419