I want to find in a XML file only the tree with for example code = "7041"
.
Here is a part of the XML file:
<lens>
<code>7041</code>
<names>
<name language="en">
<long>synchrony SV Curves HDC 1.5 PH Brn</long>
</name>
</lens>
Here is my code:
for elem in tree.findall('lenses/lens/code/[@text="7041"]'):
print (elem.tag, elem.text)
This code does not work, I do not find "7041"
. What is wrong?
How can I select only the part in the file were code="7041"
?