Read XML path into a dictionary

    0

    5

    xmlfile
    Python public recipes

    Read a XML file and return its content as a dictionary

    Shortcut: xml.file.read-as-dict

    import xmltodict
    import xml
    
    with open("filename", 'r') as xmlfile:
      try:
        result = xmltodict.parse(xmlfile.read())
      except xml.parsers.expat.ExpatError:
        # Handling error
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.