stefan_ml at behnel.de
Fri Oct 3 18:22:05 CEST 2008
Uwe Schmitt wrote:
> I have to parse some text which pretends to be XML. lxml does not want
> to parse it, because it lacks a root element.
> I think that this situation is not unusual, so: is there a way to
> force lxml to parse it ?
> My work around is wrapping the text with "<root>...</root>" before
> feeding lxmls parser.
Yes, you can do that. To avoid creating an intermediate string, you can use
the feed parser and do something like this:
parser = etree.XMLParser()
root = parser.close()
More information about the Python-list