Created
December 13, 2010 06:59
-
-
Save d1b/738738 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from lxml import etree | |
def main(): | |
doc = etree.parse("scan.xml") | |
for x in doc.xpath("//host[ports/port[state[@state='open']]]"): | |
for addr in x.xpath("address/@addr"): | |
print addr | |
for openz in x.xpath("ports/port[state[@state='open']]"): | |
print ' ',' '.join([str(items) for items in openz.attrib.values()]) | |
print ' ', '\n '.join([str(x) for child in list(openz) for x in child.attrib.iteritems()]) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment