[lxml-dev] Working with <?xml-stylesheet ... ?>

Stefan Behnel stefan_ml at behnel.de
Mon Jan 5 15:48:37 CET 2009


Hi,

Martin Aspeli wrote:
> once I get the HtmlProcessingInstruction 
> node, how can I get the value of its pseudo-attributes (href and type, 
> in this case)? The attr dict is empty...

As you say, they are not attributes. The content of a processing
instruction is application specific plain text, according to the XML
specification.

http://www.w3.org/TR/REC-xml/#sec-pi

While there is some simple support for the xml-stylesheet processing
instruction in plain lxml.etree, it's not currently enabled in lxml.html,
and it's not available for any other PI target. Your best bet is to parse
the PI content yourself (.target and .text properties).

Stefan


More information about the lxml-dev mailing list