| OLD | NEW |
| 1 :mod:`xml.dom.minidom` --- Lightweight DOM implementation | 1 :mod:`xml.dom.minidom` --- Minimal DOM implementation |
| 2 ========================================================= | 2 ===================================================== |
| 3 | 3 |
| 4 .. module:: xml.dom.minidom | 4 .. module:: xml.dom.minidom |
| 5 :synopsis: Lightweight Document Object Model (DOM) implementation. | 5 :synopsis: Minimal Document Object Model (DOM) implementation. |
| 6 .. moduleauthor:: Paul Prescod <paul@prescod.net> | 6 .. moduleauthor:: Paul Prescod <paul@prescod.net> |
| 7 .. sectionauthor:: Paul Prescod <paul@prescod.net> | 7 .. sectionauthor:: Paul Prescod <paul@prescod.net> |
| 8 .. sectionauthor:: Martin v. Löwis <martin@v.loewis.de> | 8 .. sectionauthor:: Martin v. Löwis <martin@v.loewis.de> |
| 9 | 9 |
| 10 **Source code:** :source:`Lib/xml/dom/minidom.py` | 10 **Source code:** :source:`Lib/xml/dom/minidom.py` |
| 11 | 11 |
| 12 -------------- | 12 -------------- |
| 13 | 13 |
| 14 :mod:`xml.dom.minidom` is a light-weight implementation of the Document Object | 14 :mod:`xml.dom.minidom` is a minimal implementation of the Document Object |
| 15 Model interface. It is intended to be simpler than the full DOM and also | 15 Model interface, with an API similar to that in other languages. It is intended |
| 16 significantly smaller. | 16 to be simpler than the full DOM and also significantly smaller. Users who are |
| 17 | 17 not already proficient with the DOM should consider using the |
| 18 .. note:: | 18 :mod:`xml.etree.ElementTree` module for their XML processing instead |
| 19 | |
| 20 The :mod:`xml.dom.minidom` module provides an implementation of the W3C-DOM, | |
| 21 with an API similar to that in other programming languages. Users who are | |
| 22 unfamiliar with the W3C-DOM interface or who would like to write less code | |
| 23 for processing XML files should consider using the | |
| 24 :mod:`xml.etree.ElementTree` module instead. | |
| 25 | 19 |
| 26 DOM applications typically start by parsing some XML into a DOM. With | 20 DOM applications typically start by parsing some XML into a DOM. With |
| 27 :mod:`xml.dom.minidom`, this is done through the parse functions:: | 21 :mod:`xml.dom.minidom`, this is done through the parse functions:: |
| 28 | 22 |
| 29 from xml.dom.minidom import parse, parseString | 23 from xml.dom.minidom import parse, parseString |
| 30 | 24 |
| 31 dom1 = parse('c:\\temp\\mydata.xml') # parse an XML file by name | 25 dom1 = parse('c:\\temp\\mydata.xml') # parse an XML file by name |
| 32 | 26 |
| 33 datasource = open('c:\\temp\\mydata.xml') | 27 datasource = open('c:\\temp\\mydata.xml') |
| 34 dom2 = parse(datasource) # parse an open file | 28 dom2 = parse(datasource) # parse an open file |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 utility to most DOM users. | 243 utility to most DOM users. |
| 250 | 244 |
| 251 .. rubric:: Footnotes | 245 .. rubric:: Footnotes |
| 252 | 246 |
| 253 .. [#] The encoding name included in the XML output should conform to | 247 .. [#] The encoding name included in the XML output should conform to |
| 254 the appropriate standards. For example, "UTF-8" is valid, but | 248 the appropriate standards. For example, "UTF-8" is valid, but |
| 255 "UTF8" is not valid in an XML document's declaration, even though | 249 "UTF8" is not valid in an XML document's declaration, even though |
| 256 Python accepts it as an encoding name. | 250 Python accepts it as an encoding name. |
| 257 See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl | 251 See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl |
| 258 and http://www.iana.org/assignments/character-sets . | 252 and http://www.iana.org/assignments/character-sets . |
| OLD | NEW |