DOM (document object model) is a cross-language API from W3C i.e. World Wide Web Consortium for accessing and modifying XML documents. Python enables you to parse XML files with the help of xml.dom.minidom, which is the minimal implementation of the DOM interface. It is simpler than the full DOM API and should be considered as smaller.
Steps for Parsing XML are –
- Import the module
Let say, your XML files will have the following things,
- Use the parse function to load and parse the XML file. In the below case docs stores the result of the parse function
docs = xml.dom.minidom.parse("test.xml")
- Let’s print the child tagname and nodename of the XML file.
- Now to get the information from the tag-name, you need to call dom standard function getElementsByTagName and getAttribute for fetching the required attributes.
#document info 4 skills Machine learning Deep learning Python Bootstrap
- How to Parse and Modify XML in Python?
- Create XML Documents using Python
- Read, Write and Parse JSON using Python
- NLP | Using dateutil to parse dates.
- XML parsing in Python
- Python - JSON to XML
- Python - XML to JSON
- Serialize Python dictionary to XML
- Reading and Writing XML Files in Python
- Parsing XML with DOM APIs in Python
- Modify XML files with Python
- Python IMDbPY – Series Information in XML format
- Python IMDbPY – Company Information in XML format
- Python IMDbPY – Person Information in XML format
- Python IMDbPY – Movies Information in XML format
- Python IMDbPY – Getting Series Countries as XML
- Python IMDbPY – Getting Series Run times as XML
- Python IMDbPY – Getting Series Genres as XML
- Python IMDbPY – Getting Series Cast as XML
- Turning a Dictionary into XML in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.