开发者

ExpatError: not well-formed (invalid token)

please consider this code:

import xml.etree.ElementTree as ET
import urllib

XML_response = urllib.urlopen('http://www.navlost.eu/aero/metar/?icao=LWSK&dt0=2011-05-03+12%3A00%3A00&c=1&rt=metar').read()
tree = ET.fromstring(XML_response)

Which raises this error:

---------------------------------------------------------------------------
ExpatError                                Traceback (most recent call last)
C:\Python26\<ipython-input-82-64c111a1ce76> in <module>()
----> 1 tree = ET.fromstring(XML_response)

C:\Python26\lib\xml\etree\ElementTree.pyc in 开发者_开发百科XML(text)
    961 def XML(text):
    962     parser = XMLTreeBuilder()
--> 963     parser.feed(text)
    964     return parser.close()
    965 

C:\Python26\lib\xml\etree\ElementTree.pyc in feed(self, data)
   1243 
   1244     def feed(self, data):
-> 1245         self._parser.Parse(data, 0)
   1246 
   1247     ##


**ExpatError: not well-formed (invalid token): line 12, column 28**

Here is XML_response: http://paste.pocoo.org/show/401984/

Problem is I can't see why line 12, column 28 (or regular dash ord 45 character) is linked to this error. Probably Python is trying to tell me something, but I can't see what


Double dashes are not valid within comments (other than when ending them). There was a bug filed against Expat with the same issue you have, and they rejected it with a link to the relevant standard.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜