from lxml import etree
from StringIO import StringIO
f= open ( 'xmltest2.xml' )
xml = f.read ( )
print xml
tree = etree.parse ( StringIO ( xml ) )
nodes_nmap= tree.xpath ( '//nmaprun/host/ports/port[@protocol="tcp"]' )
print "len=" , len ( nodes_nmap)
print nodes_nmap
for node in nodes_nmap: # perebrat elemeny
#print node.tag,node.keys(),node.values()
print node.values ( )
ZnJvbSBseG1sIGltcG9ydCBldHJlZQpmcm9tIFN0cmluZ0lPIGltcG9ydCBTdHJpbmdJTwpmPW9wZW4oJ3htbHRlc3QyLnhtbCcpCnhtbD1mLnJlYWQoKQpwcmludCB4bWwKdHJlZSA9IGV0cmVlLnBhcnNlKFN0cmluZ0lPKHhtbCkpCm5vZGVzX25tYXA9dHJlZS54cGF0aCgnLy9ubWFwcnVuL2hvc3QvcG9ydHMvcG9ydFtAcHJvdG9jb2w9InRjcCJdJykKcHJpbnQgImxlbj0iLCBsZW4obm9kZXNfbm1hcCkKcHJpbnQgbm9kZXNfbm1hcApmb3Igbm9kZSBpbiBub2Rlc19ubWFwOiAjIHBlcmVicmF0IGVsZW1lbnkKICAgICNwcmludCBub2RlLnRhZyxub2RlLmtleXMoKSxub2RlLnZhbHVlcygpCiAgICBwcmludCBub2RlLnZhbHVlcygp