March 2019
Beginner
490 pages
12h 40m
English
The xml.etree.ElementTree module contains the Element class, which allows you to inspect an XML document by accessing its methods and attributes, as well as the indexing of its elements.
In this example, we are reading an XML file called books.xml:
<?xml version="1.0" encoding="UTF-8"?><root> <book id="book1" name="Learning Python 2"> <title>Learning Python 2</title> <publisher>Packt Publishing</publisher> <numberOfChapters>13</numberOfChapters> <pageCount>500</pageCount> <author>Author1</author> <chapters> <chapter> <chapterNumber>1</chapterNumber> <chapterTitle>Chapter1</chapterTitle> <pageCount>30</pageCount> </chapter> <chapter> <chapterNumber>2</chapterNumber> <chapterTitle>Chapter2</chapterTitle> <pageCount>25</pageCount> ...
Read now
Unlock full access