1π
β
Your sample code works for me perfectly with Python 2.7.4 and lxml 3.2.3, the xpath()
method returning a list containing the two Restaurant
elements. If your XML parser insists that the XML file is well-formed, maybe you are giving it the wrong file, or the file is saved in a non-recognized encoding such as UTF-16.
To debug this, try printing open(settings.MEDIA_ROOT+'\\table.xml').read()
and see if the output looks like valid XML. If in doubt about the correctness of XML, itβs a good idea to also verify it using an independent tool such as xmllint
.
π€user4815162342
0π
I got it by doing so:
datei = ET.parse(settings.MEDIA_ROOT+'\\table.xml')
rests = datei.getroot()
for each in rests:
#do something with tags
thanks anyway for answers and views..
π€doniyor
Source:stackexchange.com