lxml and adding a stylesheet

Stefan Behnel stefan_ml at behnel.de
Fri Oct 3 12:17:43 EDT 2008


Sean Davis wrote:
> I have an xml document and simply need to add an xml-stylesheet to
> it.  I am using lxml to parse the xml document and then would like to
> insert the xml-stylesheet tag using the etree api.  Any suggestions?

I assume you are talking about a processing instruction here, not a tag.

Use the .addprevious() method on the root Element with a PI object.

Stefan



More information about the Python-list mailing list