Use ElementTree:

import xml.etree.ElementTree as ET
tree = ET.parse('Config.xml')
root = tree.getroot()
print(root.findall('.//Log'))

Output:

pawel@pawel-XPS-15-9570:~/test$ python parse_xml.py 
[<Element 'Log' at 0x7fb3f2eee9f
Answer from pawelbylina on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › reading-and-writing-xml-files-in-python
Reading and Writing XML Files in Python - GeeksforGeeks
January 12, 2026 - Let’s look at two libraries used for XML parsing in Python. BeautifulSoup is mainly used for HTML parsing, but when combined with the lxml parser, it can also parse XML files efficiently.
Discussions

A Roadmap to XML Parsers in Python – Real Python
Heh, this would have been so useful for me a week ago, when I needed to parse an XML. Found xmltodict and it served its purpose beautifully - for what I needed at least. More on reddit.com
🌐 r/Python
14
88
October 19, 2021
Reading and writing out an XML file as flat file?

You probably want to write a SAX parser. Look at xml.sax in the stdlib.

More on reddit.com
🌐 r/Python
4
2
March 30, 2014
How to do XML SAX parsing in python using iterparse()?

I think that elem is an Element type, so elem.attrib will be a dictionary of the attributes.

See https://docs.python.org/2/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element

edit: so, url = elem.attrib.get('href')

More on reddit.com
🌐 r/Python
1
0
January 5, 2015
How would I parse XML that I get through Pycurl?

Parsing any html or xml is easiest with BeautifulSoup. Just remember to specify that's it's XML, or it will default to HTML:

soup = bs4.BeautifulSoup(body, 'xml')
More on reddit.com
🌐 r/learnpython
4
0
October 15, 2015
🌐
Python
docs.python.org › 3 › library › xml.etree.elementtree.html
xml.etree.ElementTree — The ElementTree XML API
January 29, 2026 - If not given, the standard XMLParser parser is used. parser must be a subclass of XMLParser and can only use the default TreeBuilder as a target. Returns an iterator providing (event, elem) pairs; it has a root attribute that references the root element of the resulting XML tree once source is fully read. The iterator has the close() method that closes the internal file object if source is a filename.
🌐
Dive into Python
diveintopython.org › home › learn python programming › file handling and file operations › xml files handling
XML File Operations with Python - Read, Write and Parse XML Data
May 3, 2024 - In both of these examples, the xml.etree.ElementTree module is used to parse the XML file and extract the data. The csv module (in Example 1) or the pandas library (in Example 2) is used to write the data to a CSV file.
🌐
LearnPython.com
learnpython.com › blog › read-xml-into-python
How to Read XML Files into Python | LearnPython.com
This simple mechanism allows us to store arbitrary hierarchical structures into the XML, even if they include hundreds of elements. In fact, formats such as XLSX use XML under the hood in order to manage all the complexity behind an Excel spreadsheet. (This article shows how to read Excel files in Python directly).
🌐
Zyte
zyte.com › learn › a-practical-guide-to-xml-parsing-with-python
A Practical Guide to Python XML Parsing
Whether you're dealing with configuration files, SOAP-based APIs, or large datasets used in enterprise applications, understanding how to parse and manipulate XML is essential. In this guide, we’ll dive into the world of XML parsing using · Python, providing not just basic methods but also advanced techniques like handling XML namespaces, performing XPath queries, and mapping XML data to custom Python objects. By the end, you will have a deep understanding of how to read...
🌐
Rdegges
rdegges.com › 2013 › quickly-extract-xml-data-with-python
Randall Degges - Quickly Extract XML Data with Python
Instead of going the LXML route, ... using Python’s built in xml.etree module. It’s got a (relatively) simple interface that makes parsing simple XML documents fairly easy – and since that’s all I needed to do, it seemed like a good solution. If you’re looking for a quick way to extract XML data, read ...
Find elsewhere
🌐
DataCamp
datacamp.com › tutorial › python-xml-elementtree
Python XML Tutorial: Element Tree Parse & Read | DataCamp
December 10, 2024 - Check for common issues like malformed XML, unsupported encodings, or incorrect file paths. Use Python's error handling mechanisms (try-except blocks) to diagnose and manage parsing errors gracefully. ElementTree does not support pretty-printing directly, but you can use xml.dom.minidom to parse the XML string and then use its toprettyxml() method to format the XML for readability.
🌐
GitHub
github.com › oxylabs › how-to-parse-xml-in-python
GitHub - oxylabs/how-to-parse-xml-in-python: Follow this in-depth technical tutorial to learn how to parse XML data in Python, what libraries you should use, how to handle invalid XML, and more. · GitHub
Now, let's learn how to parse XML files using these libraries. Fortunately, both minidom and ElementTree provide a built-in function to parse XML files. You can use the parse method of minidom to read XML content from a file.
Author   oxylabs
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.read_xml.html
pandas.read_xml — pandas 3.0.1 documentation - PyData |
Read XML document into a DataFrame object. ... String path, path object (implementing os.PathLike[str]), or file-like object implementing a read() function. The string can be a path. The string can further be a URL. Valid URL schemes include http, ftp, s3, and file.
🌐
ScrapingAnt
scrapingant.com › blog › python-parse-xml
How to Parse XML in Python | ScrapingAnt
August 2, 2024 - import codecs with codecs.open("example.xml", "r", encoding="utf-8") as file: content = file.read() This approach helps prevent encoding-related parsing errors, especially when dealing with XML files from various sources. By following these best practices, developers can significantly improve the efficiency, reliability, and performance of XML parsing in Python, even when working with large and complex XML documents.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-parse-xml-in-python-without-using-external-libraries
How to Parse XML in Python Without Using External Libraries
November 12, 2025 - The xml.etree.ElementTree module works well enough for most XML parsing needs, and it's always available in Python's standard library. For more advanced XML navigation and selection, you can explore XPath expressions. XPath works well for selecting nodes in an XML document and can be very useful for complex structures. We’ll cover this in another tutorial. Until then, happy parsing! ... I'm a self-taught programmer and a technical writer from India. I enjoy reading, writing, and coding.
🌐
ScrapingDog
scrapingdog.com › blog › xml-parsing-python
How To Parse XML in Python (Detailed Guide)
May 7, 2025 - Consider this sample XML data. I am naming this file as sample.xml. Now, let’s write some Python code to parse the data from this XML file using the Parse function.
🌐
Medium
mjamilmoughal.medium.com › working-with-xml-using-python-933e39598581
Working with XML using Python. In this article we are going to learn… | by Jamil Moughal | Medium
April 17, 2021 - In this article we are going to learn how to parse, explore, modify and populate an XML file using Python ElementTree. We will understand…
🌐
The Hitchhiker's Guide to Python
docs.python-guide.org › scenarios › xml
XML parsing — The Hitchhiker's Guide to Python
Unlike other XML libraries, automatic type parsing is available, so f.e. if the schema defines an element to be of type int, the parsed dict will contain also an int value for that element. Moreover the library supports automatic and explicit validation of XML documents against a schema. from xmlschema import XMLSchema, etree_tostring # load a XSD schema file schema = XMLSchema("your_schema.xsd") # validate against the schema schema.validate("your_file.xml") # or schema.is_valid("your_file.xml") # decode a file data = schmema.decode("your_file.xml") # encode to string s = etree_tostring(schema.encode(data))
🌐
Reddit
reddit.com › r/python › a roadmap to xml parsers in python – real python
r/Python on Reddit: A Roadmap to XML Parsers in Python – Real Python
October 19, 2021 - Heh, this would have been so useful for me a week ago, when I needed to parse an XML. Found xmltodict and it served its purpose beautifully - for what I needed at least. ... Nice! Glad to read you found about xmltodict.
🌐
Oxylabs
oxylabs.io › blog › python-parse-xml
How to Parse XML in Python
Now, let’s learn how to parse XML files using these libraries. Fortunately, both `minidom` and `ElementTree` provide a built-in function to parse XML files. You can use the `parse` method of `minidom` to read XML content from a file.
🌐
Apify
blog.apify.com › python-parse-xml
How to parse XML in Python
July 16, 2025 - In this guide, you’ll learn in detail how to parse XML files in Python. Here, we’ll focus on the ElementTree API, a built-in, simple, lightweight XML processor for parsing XML. Additionally, we’ll explore extracting and parsing data from XML files using Beautiful Soup and LXML. ... Let's first understand XML, its structure, and how an XML parser functions to process and read data from XML files.
🌐
Studytonight
studytonight.com › python-howtos › how-to-read-xml-file-in-python
How to read XML file in Python - Studytonight
It parses the file because it reads it from disk and also the entire file isn't stored in memory. Reading XML using this method requires the creation of ContentHandler by subclassing xml.sax.ContentHandler. Note: This method might not be compatible with Python 3 version.
🌐
AskPython
askpython.com › home › python xml parser
Python XML Parser - AskPython
July 7, 2022 - Let’s get started! We can use the ElementTree Python library to achieve this task. This is the simplest and recommended option for building a Python XML parser, as this library comes in bundled with Python by default.