I'm trying to parse a complex XML and xpath isn't behaving like I thought it would. Here's my sample xml:
<project>
<samples>
<sample>show my balance</sample>
<sample>show me the <subsample value='USD'>money</subsample>today</sample>
</samples>
</project>
Here's my python code:
from lxml import etree
somenode="<project><samples><sample>show my balance</sample><sample>show me the <subsample value='USD'>money</subsample>today</sample></samples></project>"
somenode_etree = etree.fromstring(somenode)
for x in somenode_etree.iterfind(".//sample"):
print (etree.tostring(x))
I get the output:
b'<sample>show my balance</sample><sample>show me the <subsample value="USD">money</subsample>today</sample></samples></project>'
b'<sample>show me the <subsample value="USD">money</subsample>today</sample></samples></project>'
when I expected:
show my balance
show me the <subsample value="USD">money</subsample>today
What am I doing wrong?