Python XML Processing
What is XML ?
XML stands for eXtensible Markup Language . The XML standard is a flexible way to create information formats and electronically share structured data via the public Internet, as well as via corporate networks.
The Document Object Model (DOM) defines a standard for accessing and manipulating documents. The XML DOM defines a standard way for accessing and manipulating XML documents. It presents an XML document as a tree-structure.
XML parsing in Python
Python can parse xml documents in several ways. It has traditional dom and sax parsers. This chapter will focus on using inbuilt xml module in python for parsing XML.
Sample XML document
Copy and paste the above xml code in a text file and save it as "data.xml" in working directory.
ElementTree XML API
The xml.etree.ElementTree module implements a simple and efficient API for parsing and creating XML data. The Element type is a flexible container object, designed to store hierarchical data structures in memory.
Minimal DOM implementation(xml.dom.minidom)
The xml.dom.minidom is a minimal implementation of the Document Object Model interface, with an API similar to that in other languages. It is intended to be simpler than the full DOM and also significantly smaller. Programmers who are not already proficient with the DOM should consider using the xml.etree.ElementTree module for their XML processing instead.