Posted By

manatlan on 09/09/09


Tagged

xslt python xml lxml


Versions (?)

lxml xslt


 / Published in: Python
 

  1. from lxml.etree import XSLT,fromstring
  2.  
  3. xml = fromstring("<a key='value'>ez</a>")
  4.  
  5. xsl= fromstring("""<?xml version="1.0" encoding="UTF-8"?>
  6. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  7. <xsl:output method = "html" version="1.0" encoding="UTF-8" omit-xml-declaration="yes" standalone="yes" indent="no" />
  8.  
  9. <xsl:template match="a">
  10. <xsl:value-of select="@key"/>
  11. </xsl:template>
  12.  
  13. </xsl:stylesheet>""")
  14.  
  15. style = XSLT(xsl)
  16. result = style.apply( xml)
  17. print style.tostring(result)

Report this snippet  

You need to login to post a comment.