
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How to create Python objects based on an XML file?
Untangle
We can use untangle to create Python objects based on an XML file
untangle is a simple library which takes an XML document and returns a Python object which mirrors the nodes and attributes in its structure.
For example, an XML file like this −
<?xml version="1.0"?> <root> <child name="child1"> </root>
can be loaded like this −
import untangle obj = untangle.parse('path/to/file.xml')
and then you can get the child elements name like this −
obj.root.child['name']
untangle also supports loading XML from a string or an URL.
- Related Articles
- How to create animation using XML file in an Android App?
- How to create animation using XML file in an Android App using Kotlin?
- Python Pandas - Create an Index based on an underlying Categorical
- How to create an empty file using Python?
- How to get specific nodes in xml file in Python?
- How to add an attribute to the XML file using Powershell?
- How to create a duplicate file of an existing file using Python?
- Create XML Documents using Python
- How to create an ID column in R based on categories?
- Creating an array of objects based on another array of objects JavaScript
- How to echo XML file in PHP
- How to apply XSL transformation on an XML document?
- Filter an array containing objects based on another array containing objects in JavaScript
- How to group objects based on a value in JavaScript?
- How to create class objects in Python?

Advertisements