Dec. 31, 2008
12:17 p.m.
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