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
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
What should I use for XML parsing in python3?

If you are just doing basic XML parsing, I would recommend using ElementTree. If you are using namespaces, I would recommend switching to lxml.

BeautifulSoup is also good.

More on reddit.com
🌐 r/learnpython
14
0
April 16, 2012
What are some good xml parsers?

lxml - http://codespeak.net/lxml/

It's fully featured, fast and extremely easy to use.

More on reddit.com
🌐 r/Python
21
10
January 15, 2009
🌐
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.
🌐
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 ...
🌐
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.
🌐
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.
🌐
Pranavk
pranavk.me › python › parsing-xml-efficiently-with-python
Parsing large XML files efficiently with Python
If you don’t have it just search for a package named python-lxml if you are in Ubuntu or search for the similar package if you are on any other distribution. You can also download this package from pip or easy_install whatever you like. So, unlike the traditional parsers, what lxml will be doing is to record the events as it parses the file and probably I think it don’t capture the whole file in the memory, it just reads the file in chunks.
🌐
OpenWeatherMap
openweathermap.org › current
Current weather data
Response format. JSON format is used by default. To get data in XML format just set up mode = xml.
🌐
JSON Formatter
jsonformatter.org › xml-formatter
Best XML Formatter and XML Beautifier
Supports Tree View of XML data to navigate and helps you analyze better, makes it XML human readable. Supports xml indent levels: 2 spaces, 3 spaces, 4 spaces. XML Formatter can be used as alternative of VSCode / Sublime / Notepad++. XML tidy supports WSDL Formatter, SOAP Formatter, XSD, POM, SGML, RDF, SVG, RSS and all xml data files which represents extensible markup languages. Free XML Formatter also works as XML Converter / Convertor to JSON. Know more about XML: How to Print XML? Python XML Pretty Print ·
🌐
DataScientYst
datascientyst.com › read-xml-file-python-pandas
How to Read XML File with Python and Pandas
October 13, 2022 - In this quick tutorial, we'll cover how to read or convert XML file to Pandas DataFrame or Python data structure. Since version 1.3 Pandas offers an elegant solution for reading XML files: pd.read_xml(). The short solutions is: df = pd.read_xml('sitemap.xml') With the single line
🌐
Roy Tutorials
roytuts.com › home › python › parsing xml using python
Parsing XML using Python - Roy Tutorials
November 22, 2023 - If you want to parse or read XML string then use root = ET.fromstring(book_data_as_string). Here in the below script I first import the required module and then I load or parse the whole XML file into tree variable. Then I get the root node from the XML data. Finally I iterate through each level of the node and print the node name, node attributes and node value. Lets create the Python script (xml-parser.py) to read the above XML file:
🌐
Python
docs.python.org › 3 › library › xml.html
XML Processing Modules — Python 3.14.3 documentation
The built-in XML parsers of Python rely on the library libexpat, commonly called Expat, for parsing XML. By default, Expat itself does not access local files or create network connections.
🌐
Fremontleaf
wiki.fremontleaf.org › official-files › xml-parsing-in-python-a-guide-to-elementtree-1767648606
XML Parsing In Python: A Guide To ElementTree
January 5, 2026 - Finally, we use tree.write() to save the modified XML to a new file, books_modified.xml. Always remember after modifications, import xml etree elementtree as et and then to write the changes back. This demonstrates the power of ElementTree to not only read but also dynamically change the contents of your XML files.