Richard
Richard

Reputation: 1690

lxml only loading a single network entity before raising XMLSyntaxError

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?

Upvotes: 1

Views: 637

Answers (1)

John Machin
John Machin

Reputation: 82934

Known unfixed bug.

Use urllib2.urlopen() to get a file-like object and pass that to lxml.etree.parse()

Upvotes: 3

Related Questions