This might be a newbie question 🙂 but it’s irritating me since I’m new to XML. I have the following xml file:
<assetsMain>
<assetParent type='character' shortName='char'>
<asset>
pub
</asset>
<asset>
car
</asset>
</assetParent>
<assetParent type='par' shortName='pr'>
<asset>
camera
</asset>
<asset>
rig
</asset>
</assetParent>
</assetsMain>
Is it possible to retrieve all <assetParent> nodes and all their attributes and children texts? For example to have the result as the following:
[ [['character','char'],['pub','car']]
[['par','pr'],['camera','rig']]
]
By the way, I use DOM and Python 2.6
Thanks in advance.
An answer using lxml.etree. Xpath would probably be reusable in another capable library: