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
🌐
Python
docs.python.org › 3 › library › xml.etree.elementtree.html
xml.etree.ElementTree — The ElementTree XML API
January 29, 2026 - Sometimes what the user really wants is to be able to parse XML incrementally, without blocking operations, while enjoying the convenience of fully constructed Element objects. The most powerful tool for doing this is XMLPullParser. It does not require a blocking read to obtain the XML data, and is instead fed with data incrementally with XMLPullParser.feed() calls.
🌐
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).
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
How do I parse xml file after reading a bit first
Probably the most pythonic way is to try to parse it as xml, and catch the exception if it doesn’t parse. More on reddit.com
🌐 r/learnpython
6
1
May 23, 2025
How to process / parse XML with Python
Best bet: Use lxml . There's a nice tutorial on the site, too . You can also use the built-in XML parser, either with ElementTree (common) or XML DOM (rarer) , or any other related library from the xml module , but most people prefer lxml, as it's much more powerful (and in parts, compatible with ElementTree). More on reddit.com
🌐 r/learnpython
5
11
October 22, 2017
Parsing XML into a Pandas dataframe
To parse an XML file into a Pandas DataFrame, you can use the from_dict method of the DataFrame class. First, you will need to use the ElementTree module to parse the XML file and extract the relevant data. Here is an example of how this can be done: import xml.etree.ElementTree as ET import pandas as pd Parse the XML file using ElementTree tree = ET.parse('my_file.xml') root = tree.getroot() Extract the column names from the 'columns' element columns = [col.attrib['friendlyName'] for col in root.find('columns')] Create an empty list to store the data for each row data = [] Iterate over the 'row' elements and extract the data for each one for row in root.find('rows'): row_data = {} for col in row: # Add the data for each column to the dictionary row_data[col.attrib['name']] = col.text # Add the dictionary for this row to the list data.append(row_data) Create a DataFrame using the column names and data df = pd.DataFrame.from_dict(data, columns=columns) This code will parse the XML file and extract the data for each row and column, storing it in a dictionary. The dictionary is then used to create a DataFrame using the from_dict method. This DataFrame will have the column names as the columns and each row of data as a row in the DataFrame. More on reddit.com
🌐 r/learnpython
8
3
December 9, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › python › reading-and-writing-xml-files-in-python
Reading and Writing XML Files in Python - GeeksforGeeks
January 12, 2026 - from bs4 import BeautifulSoup with open('dict.xml', 'r') as f: data = f.read() bs_data = BeautifulSoup(data, 'xml') for tag in bs_data.find_all('child', {'name':'Frank'}): tag['test'] = "WHAT !!" print(bs_data.prettify()) ... ElementTree is included in Python’s standard library, so no installation is required.
🌐
Zyte
zyte.com › learn › a-practical-guide-to-xml-parsing-with-python
A Practical Guide to Python XML Parsing
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, modify, and write XML files efficiently using Python.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.read_xml.html
pandas.read_xml — pandas 3.0.1 documentation - PyData |
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. ... The XPath to parse required set of nodes for migration to DataFrame.``XPath`` should return a collection of elements and not a single element. Note: The etree parser supports limited XPath expressions. For more complex XPath, use lxml which requires installation. ... The namespaces defined in XML document as dicts with key being namespace prefix and value the URI.
🌐
DataCamp
datacamp.com › tutorial › python-xml-elementtree
Python XML Tutorial: Element Tree Parse & Read | DataCamp
December 10, 2024 - Parse and read XML data with Element Tree Python package. Learn how to use xml.etree.elementtree and explore your data through XML today!
Find elsewhere
🌐
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
🌐
The Hitchhiker's Guide to Python
docs.python-guide.org › scenarios › xml
XML parsing — The Hitchhiker's Guide to Python
can be loaded into a Python dict like this: import xmltodict with open('path/to/file.xml') as fd: doc = xmltodict.parse(fd.read()) and then you can access elements, attributes, and values like this: doc['mydocument']['@has'] # == u'an attribute' doc['mydocument']['and']['many'] # == [u'elements', u'more elements'] doc['mydocument']['plus']['@a'] # == u'complex' doc['mydocument']['plus']['#text'] # == u'element as well' xmltodict also lets you roundtrip back to XML with the unparse function, has a streaming mode suitable for handling files that don’t fit in memory, and supports XML namespaces.
🌐
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.
🌐
Real Python
realpython.com › ref › stdlib › xml
xml | Python Standard Library – Real Python
>>> import xml.etree.ElementTree as ET >>> root = ET.fromstring("<data><item>Python</item></data>") >>> root.tag 'data' Parses XML documents from strings, file, and other data sources · Supports both SAX and DOM parsing models · Allows creation and modification of XML documents · Provides an API through ElementTree for common XML tasks · Handles Unicode and namespaces in XML documents · Supports reading and writing XML in both compact and pretty-printed formats ·
🌐
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 - Glad to read you found about xmltodict. I would suggest you though, go over this tutorial as you might learn a few other tricks. ... I just refuse to use anything with xml. Json or yaml only. ... always use lxml, whether going for etree-style, sax-style, or pull parsing. (using another frontend on top of lxml is still valid) don't use lxml.objectify. Instead, pass a custom lookup to the parser (trivial if using LXML's builtin xml/html parsing support; easy enough if you use bs4 as your frontend (just pass parser.makeelement).
🌐
Real Python
realpython.com › python-xml-parser
A Roadmap to XML Parsers in Python – Real Python
September 25, 2023 - Finally, the SAX model just allows for read-only parsing. In short, SAX is cheap in terms of space and time but more difficult to use than DOM in most cases. It works well for parsing very large documents or parsing incoming XML data in real time. Although somewhat less popular in Python, this ...
🌐
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 - We convert numeric strings to proper types (float for price, int for stock) For nested categories, we first check if the <categories> element exists. Then we iterate through child <category> elements and collect their text · The result is clean Python data structures you can easily work with. You can now use the parser like so: products = parse_product_catalog('products.xml') for product in products: print(f"\nProduct: {product['name']}") print(f" ID: {product['id']}") print(f" Price: {product['currency']} {product['price']}") print(f" Stock: {product['stock']}") print(f" Categories: {', '.join(product['categories'])}")
🌐
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.
🌐
ScrapingDog
scrapingdog.com › blog › xml-parsing-python
How To Parse XML in Python (Detailed Guide)
May 7, 2025 - Walks through two Python options for XML: ElementTree first, then Minidom. ElementTree: quick to load/parse XML and extract tag/text, good default for most tasks. Minidom: full DOM-style navigation and node control when you need detailed structure ...
🌐
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 ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › xml-parsing-python
XML parsing in Python - GeeksforGeeks
June 28, 2022 - The RSS format itself is relatively easy to read both by automated processes and by humans alike. The RSS processed in this tutorial is the RSS feed of top news stories from a popular news website. You can check it out here. Our goal is to process this RSS feed (or XML file) and save it in some other format for future use. Python Module used: This article will focus on using inbuilt xml module in python for parsing XML and the main focus will be on the ElementTree XML API of this module.
🌐
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 ...
🌐
Studytonight
studytonight.com › python-howtos › how-to-read-xml-file-in-python
How to read XML file in Python - Studytonight
In this article, we will learn how to use different parsing modules to read XML documents in Python and some related custom examples as well.