MCPcopy Create free account
hub / github.com/Parimal-shaw/NMapify / xml_parser

Function xml_parser

NMapify.py:75–105  ·  view source on GitHub ↗
(file_path)

Source from the content-addressed store, hash-verified

73 files.close()
74
75def xml_parser(file_path):
76 new_list2 = []
77 for event, elem in etree.iterparse(file_path, events=("end",), tag="host"):
78 address = elem.find(".//address")
79 if address is not None:
80 new_list2.append(address.attrib.get("addr"))
81 #print("Address:", address.attrib.get("addr"))
82 #print("Address type:", address.attrib.get("addrtype"))
83
84 for port in elem.findall(".//port"):
85 #portid = port.attrib.get("portid")
86 #protocol = port.attrib.get("protocol")
87 #print("Port ID:", portid)
88 new_list2.append(port.attrib.get("portid")+'/'+port.attrib.get("protocol"))
89 #print("Protocol:", protocol)
90
91 state_elem = port.find("state")
92 state = state_elem.attrib.get("state") if state_elem is not None else "unknown"
93 #print("State:", state)
94
95 service_elem = port.find("service")
96 #service = service_elem.attrib.get("name") if service_elem is not None else "unknown"
97 #print("Service:", service)
98 new_list2.append(service_elem.attrib.get("name"))
99
100 # Free memory
101 elem.clear()
102 #print(new_list2)
103
104 rprint("[green]Fetching Data from XML file ...[/green]")
105 GenerateXML(new_list2)
106
107def normal_parser(normal_file_output):
108 normal_list2 = []

Callers 1

NMapify.pyFile · 0.85

Calls 1

GenerateXMLFunction · 0.85

Tested by

no test coverage detected