[lxml-dev] Working with <?xml-stylesheet ... ?>
Stefan Behnel
stefan_ml at behnel.de
Wed Dec 31 13:17:26 CET 2008
Hi,
Martin Aspeli wrote:
> I'd like to quickly/efficiently get a list of all <?xml-stylesheet ?>
> processing instructions in a given document.
reversed( el for el in root.itersiblings(preceding=True)
if el.tag is etree.ProcessingInstruction
and el.target == "xml-stylesheet" )
> Also, serialising using lxml.html.tostring() seems to lose the
> <?xml-stylesheet ?> PI. Is this by design?
You need to wrap the root element in an ElementTree and serialise that.
Stefan
More information about the lxml-dev
mailing list