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 - 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.
Discussions

Can Python read/write XML and Excel XLSX files?
I’ve been doing tutorials about ... be making. User goes to a specific URL, one for each specific program. For example, one URL will be to read business card XML files and spit out...... More on discuss.python.org
🌐 discuss.python.org
0
0
January 9, 2024
Code to read and parse XML data
Good Morning, I have several thousand XML files that i need to parse and process. To that end I was reviewing a possible solution How to get an XML element text in a LibreOffice Basic macro? - Stack Overflow Rather than use OLE Automation, I prefer to use native libraries provide by LO. More on ask.libreoffice.org
🌐 ask.libreoffice.org
1
0
July 25, 2022
Read xml column inside csv file with Python
Hi, I am very new in Python and need to read an xml column inside a csv file with Python. I can see some code on google on how to read that csv file but I don’t know how to read the xml column inside the csv file. Can someone help? any idea would be appreciated. Thank you! More on discuss.python.org
🌐 discuss.python.org
0
0
April 24, 2022
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
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.read_xml.html
pandas.read_xml — pandas 3.0.1 documentation
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.
🌐
GeeksforGeeks
geeksforgeeks.org › python › reading-and-writing-xml-files-in-python
Reading and Writing XML Files in Python - GeeksforGeeks
January 12, 2026 - To modify an XML file, you first parse it, then change attributes or content, and finally save or print it. ... 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.
🌐
OneUptime
oneuptime.com › home › blog › how to work with xml files in python
How to Work with XML Files in Python
January 25, 2026 - Python's xml.etree.ElementTree module is included in the standard library and handles most XML tasks well. # xml_reader.py # Reading and parsing XML files with ElementTree import xml.etree.ElementTree as ET def read_xml_file(filepath): """Read and parse an XML file, returning the root element.""" # Parse the XML file and get the tree structure tree = ET.parse(filepath) # Get the root element of the tree root = tree.getroot() return root def extract_book_data(root): """Extract book information from the XML structure.""" books = [] # Find all 'book' elements under the root for book in root.finda
🌐
The Hitchhiker's Guide to Python
docs.python-guide.org › scenarios › xml
XML parsing — The Hitchhiker's Guide to Python
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.
Find elsewhere
🌐
Python.org
discuss.python.org › python help
Can Python read/write XML and Excel XLSX files? - Python Help - Discussions on Python.org
January 9, 2024 - User goes to a specific URL, one for each specific program. For example, one URL will be to read business card XML files and spit out a XLSX and CSV file in the exact same format containing the information from all XML files.
🌐
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 ·
🌐
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...
🌐
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.
🌐
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.
🌐
Mirketa
mirketa.com › home › blog › xml parsing: using minidom vs element tree (etree) in python
XML Parsing in Python with ElementTree & BeautifulSoup
July 23, 2025 - Explore how to parse and manipulate XML data using Python libraries like ElementTree, BeautifulSoup, and lxml.
🌐
MicroPyramid
micropyramid.com › blog › building-and-parsing-xml-document-using-python
Building and Parsing XML Document using Python | MicroPyramid
In addition to parsing XML, xml.etree.ElementTree used for creating well-formed documents from Element objects in an application. The Element class used when a document is parsed also knows how to generate a serialized form of its contents, which can then be written to a file.
🌐
ProjectPro
projectpro.io › recipes › parse-xml-in-python
Python parse xml - Parse xml python - Projectpro
December 21, 2022 - Parsing XML in python using Minidom The World Wide Web Consortium's DOM (document object model) is a cross-language API for reading and changing XML content. Python allows you to parse XML files using xml.dom.minidom.
🌐
Decodo
decodo.com › blog › parse-xml-python
Learn How to Parse XML in Python
Those are the basics of using XPath queries with Python to get data from an XML file. You may also use libraries such as lxml or libxml2 that can do the same job for you. Read their dedicated documentation to learn more about using them together with Python to parse XML files.
🌐
AskPython
askpython.com › home › python xml parser
Python XML Parser - AskPython
July 7, 2022 - This will automatically read the XML input file and get the root node for us. ... Okay, so it seems that is has parsed. But we cannot verify it yet. So let’s parse the other attributes and try to get its value. So now, our task is to get the value inside the <heading> attribute, with the use of our Python ...
🌐
Quora
quora.com › How-do-you-parse-an-XML-document-using-Python-3-x
How to parse an XML document using Python 3.x - Quora
Answer: Python XML with ElementTree The XML tree structure makes navigation, modification, and removal relatively simple programmatically. Python has a built in library, [code ]ElementTree[/code], that has functions to read and manipulate XMLs (and ...
🌐
Python.org
discuss.python.org › python help
Read xml column inside csv file with Python - Python Help - Discussions on Python.org
April 24, 2022 - Hi, I am very new in Python and need to read an xml column inside a csv file with Python. I can see some code on google on how to read that csv file but I don’t know how to read the xml column inside the csv file. Can …
🌐
Rayobyte
rayobyte.com › blog › parse-xml-file-in-python
How To Use Python To Parse XML Files
August 8, 2023 - If you use Python-based programs for your web scraping needs, you must understand how to parse XML files in Python. You can boil the process of parsing XML files down to a few steps to access, read, and extract the data in an XML file.