我收到一個名爲xml的參數,其中包含一個xml文檔。這就是我試圖...Django XML無法加載外部實體
from lxml.cssselect import CSSSelector, etree
from lxml.etree import fromstring
if request.POST:
parser = etree.XMLParser(ns_clean=True, recover=True)
h = etree.parse(request.POST['xml'], parser)
return HttpResponse(h)
,但我得到這個錯誤:
[Fri Apr 05 09:50:13 2013] [error] IOError: Error reading file '<?xml version="1.0" encoding="ISO-8859-1"?>
[Fri Apr 05 09:50:13 2013] [error] <delivery_receipt>
[Fri Apr 05 09:50:13 2013] [error] <version>1.1</version>
[Fri Apr 05 09:50:13 2013] [error] <msisdn>447777111111</msisdn>
[Fri Apr 05 09:50:13 2013] [error] <submission_ref>123456789</submission_ref>
[Fri Apr 05 09:50:13 2013] [error] <status>Delivered</status>
[Fri Apr 05 09:50:13 2013] [error] <reason>4</reason>
[Fri Apr 05 09:50:13 2013] [error] <gmt_timestamp>20130405095100</gmt_timestamp>
[Fri Apr 05 09:50:13 2013] [error] <retry>0</retry>
[Fri Apr 05 09:50:13 2013] [error] </delivery_receipt>': failed to load external entity "<?xml version="1.0" encoding="ISO-8859-1"?>
[Fri Apr 05 09:50:13 2013] [error] <delivery_receipt>
[Fri Apr 05 09:50:13 2013] [error] <version>1.1</version>
[Fri Apr 05 09:50:13 2013] [error] <msisdn>447777111111</msisdn>
[Fri Apr 05 09:50:13 2013] [error] <submission_ref>123456789</submission_ref>
等
什麼想法?謝謝:)
你好,這給出了編碼聲明Unicode字符串,不支持:(您的答覆 – Prometheus 2013-04-05 09:18:38