Posted By

manatlan on 09/09/09


Tagged

python xml XPath lxml


Versions (?)

lxml xpath


 / Published in: Python
 

  1. from lxml.etree import fromstring
  2.  
  3. xml = fromstring("""<r xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4. <a key='value'>ez</a>
  5. <a key='value2'>ez2</a>
  6. <xsl:param>toto</xsl:param>
  7. </r>""")
  8. print xml.xpath("//a")
  9. print xml.xpath("//a/@key")
  10. print xml.xpath("//xsl:param",{"xsl":"http://www.w3.org/1999/XSL/Transform"})

Report this snippet  

You need to login to post a comment.