-
-
Save lost-rob0t/5a5cd1239776acabfc72b962d7e5fadc to your computer and use it in GitHub Desktop.
Nmap XML output to Json
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
import json,xmltodict | |
""" | |
Nmap XML Output to Json Output in Python | |
example : data = xml2json('nmap_output.xml') | |
""" | |
def xml2json(xml): | |
xmlfile = open(xml) | |
xml_content = xmlfile.read() | |
xmlfile.close() | |
xmljson = json.dumps(xmltodict.parse(xml_content), indent=4, sort_keys=True) | |
jsondata = json.loads(xmljson) | |
return jsondata | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment