Skip to content
Advertisement

Parse xsi:type=”” in Python using ElementTree

I know there are a few similar questions but none of the solutions seemed to work. I need to parse and XML file using python. I am using Elementree I am trying to print the value X. It is working as long as I am just looking for X-Values within EndPosition but I have to look for within all MoveToType. Is there someway to integrate that in Elementree. Thanks!

XML file:

JavaScript

Python code:

JavaScript

Advertisement

Answer

Here is how you can get the wanted X value for MiddleCommand elements with xsi:type="MoveToType". Note that you need to use the full namespace URI inside curly braces when getting the value of the attribute.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement