fork download
  1. from lxml import etree
  2. from StringIO import StringIO
  3. f=open('xmltest2.xml')
  4. xml=f.read()
  5. print xml
  6. tree = etree.parse(StringIO(xml))
  7. nodes_nmap=tree.xpath('//nmaprun/host/ports/port[@protocol="tcp"]')
  8. print "len=", len(nodes_nmap)
  9. print nodes_nmap
  10. for node in nodes_nmap: # perebrat elemeny
  11. #print node.tag,node.keys(),node.values()
  12. print node.values()
Runtime error #stdin #stdout #stderr 0.02s 44680KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "<builtin>/app_main.py", line 75, in run_toplevel
  File "prog.py", line 1, in <module>
    from lxml import etree
ImportError: No module named lxml