I tried to search xml file, using xpath, with code:
import xml.etree.ElementTree as ET
tree = ET.parse('example.xml')
root = tree.getroot()
for node in root.findall('.//call/moc/digit'):
print("node: ", node.text)
I got :
node: 398
node: 3989
But if the xml file has attribute for call, , then the code finds nothing. I also tried with
root.findall('.//call[@xmlns=test]')
which also fails.
The exmple.xml:
<data>
<call> // If I have <call xmlns="test">, the code found nothing, why?
<moc>
<name>0</name>
<instance>
<code>11</code>
</instance>
<digit>398</digit>
<number>100</number>
</moc>
<moc>
<name>1</name>
<instance>
<code>110</code>
</instance>
<digit>3989</digit>
<number>1000</number>
</moc>
</call>
<count>900</count>
</data>
Thank you for any suggestions in advance.