ParseXML.py 482 B

123456789101112131415
  1. import xml.etree.ElementTree as ET
  2. # Parses an XML File at the given location
  3. # It is assumed, that packets are placed on the second hierarchical level and packetinformation encoded as attributes
  4. # Returns a List of Dictionaries, each Dictionary contains the information for one packet
  5. def ParseXML(path_xml):
  6. tree = ET.parse(path_xml)
  7. root = tree.getroot()
  8. #Convert Tree to List of Dictionaries
  9. packets = []
  10. for child in root:
  11. packets.append(child.attrib)
  12. return packets