写一段python脚本实现识别arxml文件里所有attrib的key是DEST的标签
你可以使用xml.etree.ElementTree模块来解析XML文件,并使用findall方法来查找所有具有特定属性的元素。以下是一个示例脚本,用于识别arxml文件中所有具有key属性为"DEST"的标签:
import xml.etree.ElementTree as ET
def find_destination_tags(filename):
tree = ET.parse(filename)
root = tree.getroot()
destination_tags = []
for elem in root.iter():
if 'key' in elem.attrib and elem.attrib['key'] == 'DEST':
destination_tags.append(elem.tag)
return destination_tags
# 示例用法
filename = 'example.arxml'
destination_tags = find_destination_tags(filename)
print(destination_tags)
请将example.arxml替换为你要解析的ARXML文件的路径。这段脚本将返回一个包含所有具有key属性为"DEST"的标签的列表
原文地址: https://www.cveoy.top/t/topic/hLeq 著作权归作者所有。请勿转载和采集!