fork(1) download
  1. import xml.etree.ElementTree as ET
  2. html = '<div> <div id="abc 123"></div> <div id="def hhh"></div> <div id="ghi test"></div> </div>'
  3. root = ET.fromstring(html)
  4.  
  5. try:
  6. print( root.findall("//div[starts-with(@id, 'def')]") )
  7. except SyntaxError as e:
  8. print e
  9.  
Success #stdin #stdout 0.01s 8012KB
stdin
Standard input is empty
stdout
cannot use absolute path on element