I am writing code to work with Amazon query based APIs, which return XML which I then wish to parse with lxml. I have written several functions which work perfectly to load the XML and parse it.
Each function loads the XML using:
variable = lxml.etree.parse("http://...")
This works perfectly, the FIRST time it is run. However, if I wish to load a second URL (be it the same one, or a different one) during the course of a running python session, I get the error:
lxml.etree.XMLSyntaxError: Attempt to load network entity http://...
(Of course, the ellipses are replaced in both cases with the rest of the URL.)
Therefore, for some reason, I appear to be unable to load two XML documents using the parse method in a running python session.
Does anyone know what I may 开发者_开发知识库be doing wrong here, or have a solution?
Known unfixed bug.
Use urllib2.urlopen()
to get a file-like object and pass that to lxml.etree.parse()
精彩评论