On 12/05/2022 22:32, Adrian Bool wrote:
On 12 May 2022, at 10:26, Gilles <[email protected]> wrote:
  File "src\lxml\parser.pxi", line 652, in lxml.etree._raiseParseError
OSError: Error reading file*'<html>*

Look at the last line above - you're giving parse() a string containing XML data which the parse() function is treating as a filename; trying to open a file with a name equivalent to your XML content!

If you want to parse an XML string - use et.fromstring() instead.

The StringIO call may be reasonable if your XML didn't exist on disk; but if your source data is on disk best to either give parse() the filename (but then you get your #13 issue) or pass it a file handle provided by open().

Sorry I overlooked the last line. I dumbly supposed that parse() could take either a file handle or a string.
_______________________________________________
lxml - The Python XML Toolkit mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/lxml.python.org/
Member address: [email protected]

Reply via email to