你可以使用xml.etree.ElementTree模块来解析XML文件,并通过遍历找到所有具有DEST属性的标签。

下面是一个示例脚本:

import xml.etree.ElementTree as ET

def find_tags_with_dest(file_path):
    # 解析XML文件
    tree = ET.parse(file_path)
    root = tree.getroot()

    # 遍历所有标签
    tags_with_dest = []
    for elem in root.iter():
        # 检查是否具有DEST属性
        if 'DEST' in elem.attrib.keys():
            tags_with_dest.append(elem.tag)

    return tags_with_dest

# 示例用法
file_path = 'path/to/arxml_file.arxml'
tags_with_dest = find_tags_with_dest(file_path)
print(tags_with_dest)

你需要将'path/to/arxml_file.arxml'替换为你自己的AUTOSAR arxml文件的路径。脚本会输出所有具有DEST属性的标签

写一段python脚本实现识别AUTOSAR arxml文件里所有attrib的key是DEST的标签

原文地址: https://www.cveoy.top/t/topic/hLeu 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录