Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 13th, 2012  |  syntax: None  |  size: 0.20 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. querying abstract elements in xpath with python
  2. import lxml.etree as etree
  3. def find(s,attrib,tagtype='*'):
  4.     tree = etree.fromstring(s)
  5.     return tree.xpath(r'.//%s[@*="%s"]'%(tagtype,attrib))