xml very newbie here.
I have an xml file, which is quite big with this form:
<a>
<b>
<id>1</id>
...
</b>
<b>
<id>2</id>
...
</b>
<b>
<id>3</id>
...
</b>
<b>
<id>4</id>
...
</b>
</a>
In b there is some information I want to retrieve and I am trying to follow a python help doc.
I start with this:
#!/usr/bin/env python
import xml.etree.ElementTree as ET
tree = ET.parse('data.xml')
root = tree.getroot()
print 'root.tag = ', root.tag
print 'root.attrib = ', root.attrib
but because my file is to big, it takes several minutes just to do this part.
What I want to do is something like this:
for node in (n for n in nodes if n.id in ['1', '3']):
print node.val1
print node.val2
(without having to process all the nodes that don't match the id I want).
Is there a way of doing this?