Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

autosar

Is there any way to indent an arxml file without importing autosar module through python language.Thanks in advance...

0 Kudos
Message 1 of 4
(3,324 Views)

*.arxml as I undersatnd is XML but with an AUTOSAR specific schema. So you should be able to do the same manipulation as you would with any XML parser/editor. 

 

For python specifically it looks like ElementTree is the standard solution for XML, 

https://docs.python.org/3/library/xml.etree.elementtree.html#module-xml.etree.ElementTree

Tim A.
0 Kudos
Message 2 of 4
(3,305 Views)

Try ElementTreeFirst build an Element instance root from the XML, e.g. with the XML function, or by parsing a file with something like:

import xml.etree.ElementTree as ET
root = ET.parse('thefile.xml').getroot()

Or any of the many other ways shown at ElementTree. Then do something like:

for type_tag in root.findall('bar/type'):
    value = type_tag.get('foobar')
    print(value)

And similar, usually pretty simple, code patterns.

0 Kudos
Message 3 of 4
(2,861 Views)

Hi Ankit@1,

 

What do you mean by indenting? What do you need to with the ARMXL file, eg read from or write to it? 

 

Thanks,

Frank

0 Kudos
Message 4 of 4
(2,842 Views)