Error 'failed to load external entity' when using Python lxml

paulalexjmekaka

New Member
I'm trying to parse an XML document I retrieve from the web, but it crashes after parsing with this error:\[code\]': failed to load external entity "<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="http://stackoverflow.com/questions/10457564/GreenButtonDataStyleSheet.xslt"?>\[/code\]That is the second line in the XML that is downloaded. Is there a way to prevent the parser from trying to load the external entity, or another way to solve this? This is the code I have so far:\[code\]import urllib2import lxml.etree as etreefile = urllib2.urlopen("http://www.greenbuttondata.org/data/15MinLP_15Days.xml")data = http://stackoverflow.com/questions/10457564/file.read()file.close()tree = etree.parse(data)\[/code\]
 
Back
Top