I have a XML code like:
<?xml version='1.0' encoding="UTF-8"?>
<coureurs>
<coureur>
<nom>Patrick</nom><hair>Inexistants</hair>
</coureur>
</coureurs>
And i want to print that:
Patrick inexistents
Etc...
For now my code is :
from lxml import etree
tree = etree.parse(file.xml)
for coureur in tree.xpath("/coureurs/coureur/nom"):
print(user.text)
but it returns blank, when i do: for user in tree.xpath("/coureurs/coureur/hair"): it only returns hair. what should i do?
for user in tree.xpath("/users/user/hair"):would not be working, it would not even return the hair, but you said it returns the hair in your question.