Last active
March 14, 2023 03:36
-
-
Save safebuffer/68b27f254208f873863fa67db0dceefe to your computer and use it in GitHub Desktop.
Nmap XML output to Json
This file contains 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