[Python] Parsing arxml file with python

Discussão em 'Python' iniciado por Stack, Fevereiro 3, 2025.

  1. Stack

    Stack Membro Participativo

    I have a file I need to parse, I need the information. The order of parsing is important.

    1. I can parse the file and get the information, but not in the sequence.
    2. How can I parse the information <MSR-QUERY-ARG SI="HtmlAnchor">?

    Btw: Where can I upload the arxml file?

    File-Download: ARXML-FILE

    from xml.etree import ElementTree as ET
    import csv

    fpath = "test.arxml"

    tree = ET.parse(fpath)
    root = tree.getroot()

    ns = {'ns':'http://autosar.org/schema/r4.0'}

    for arpackage in tree.findall('.//ns:CHAPTER/ns:TRACE',namespaces=ns):
    print(arpackage.findall('.//ns:SHORT-NAME', namespaces=ns)[0].text)

    for arpackage in tree.findall('.//ns:CHAPTER/ns:MSR-QUERY-P-1', namespaces=ns):
    print(arpackage.findall('.//ns:MSR-QUERY-ARG', namespaces=ns)[0].text)

    Continue reading...

Compartilhe esta Página