Skip to content

Instantly share code, notes, and snippets.

@swhume
Created September 25, 2021 01:40
Show Gist options
  • Save swhume/0c5d6b945ce5ad213be75b54ce83f970 to your computer and use it in GitHub Desktop.
Save swhume/0c5d6b945ce5ad213be75b54ce83f970 to your computer and use it in GitHub Desktop.
import sys
import xml.etree.ElementTree as ET
""" Simple program snippet to demonstrate parsing the CXL XML CMAP export format """
ET.register_namespace('', "http://cmap.ihmc.us/xml/cmap/")
# get the CXL file to parse from the command-line
if len(sys.argv) > 1:
cxl_file = sys.argv[1]
else:
print("Please include the CXL filename with path on the command-line.")
sys.exit()
# parse the file and get the root element
tree = ET.parse(cxl_file)
root = tree.getroot()
# print the elements in the CXL file with their attributes
for elem in root.iter():
print(f"{elem.tag.split('}')[1]}: {elem.attrib}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment