Python lxml / XPathEvalError : Invalid expression when I parse xml file



I try to parse an XML file with lxml. It works with some files but the last one gave me an error:



XPathEvalError at /admin/xml_exportation/xml/add/
Invalid expression


Here is the xml code :



<?xml version="1.0" encoding="utf-8" ?>
<export source="Source" version="1.0" date="2014-02-21T17:46:57">
<Agence ID="XX1" externRef="XX1" customCode="38495">
<Biens>
<Bien ID="XX1-176" ref="XX1-176">
<DateMAJ>2013-06-14T12:12:07</DateMAJ>
</Bien>
<Biens>
</Agence>
</export>


And then the python code :



tree = etree.parse(xml_file)
root_path = '/export/Agence/Biens/Bien/'
for element in tree.xpath(root_path):
print(element)


I tried to change the path but it gave me the same error.


Thank you for your help.


No comments:

Post a Comment