gooderp18绿色标准版
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

639 rindas
52KB

  1. <!DOCTYPE html>
  2. <html lang="en" data-content_root="../">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <meta property="og:title" content="xml.dom.minidom — Minimal DOM implementation" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/library/xml.dom.minidom.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="Source code: Lib/xml/dom/minidom.py 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 ..." />
  11. <meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
  12. <meta property="og:image:alt" content="Python documentation" />
  13. <meta name="description" content="Source code: Lib/xml/dom/minidom.py 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 ..." />
  14. <meta property="og:image:width" content="200" />
  15. <meta property="og:image:height" content="200" />
  16. <meta name="theme-color" content="#3776ab" />
  17. <title>xml.dom.minidom — Minimal DOM implementation &#8212; Python 3.12.3 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
  18. <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
  19. <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=bb723527" />
  20. <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=b20cc3f5" />
  21. <script src="../_static/documentation_options.js?v=2c828074"></script>
  22. <script src="../_static/doctools.js?v=888ff710"></script>
  23. <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
  24. <script src="../_static/sidebar.js"></script>
  25. <link rel="search" type="application/opensearchdescription+xml"
  26. title="Search within Python 3.12.3 documentation"
  27. href="../_static/opensearch.xml"/>
  28. <link rel="author" title="About these documents" href="../about.html" />
  29. <link rel="index" title="Index" href="../genindex.html" />
  30. <link rel="search" title="Search" href="../search.html" />
  31. <link rel="copyright" title="Copyright" href="../copyright.html" />
  32. <link rel="next" title="xml.dom.pulldom — Support for building partial DOM trees" href="xml.dom.pulldom.html" />
  33. <link rel="prev" title="xml.dom — The Document Object Model API" href="xml.dom.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/library/xml.dom.minidom.html" />
  35. <style>
  36. @media only screen {
  37. table.full-width-table {
  38. width: 100%;
  39. }
  40. }
  41. </style>
  42. <link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
  43. <link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
  44. <script type="text/javascript" src="../_static/copybutton.js"></script>
  45. <script type="text/javascript" src="../_static/menu.js"></script>
  46. <script type="text/javascript" src="../_static/search-focus.js"></script>
  47. <script type="text/javascript" src="../_static/themetoggle.js"></script>
  48. </head>
  49. <body>
  50. <div class="mobile-nav">
  51. <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
  52. aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
  53. <nav class="nav-content" role="navigation">
  54. <label for="menuToggler" class="toggler__label">
  55. <span></span>
  56. </label>
  57. <span class="nav-items-wrapper">
  58. <a href="https://www.python.org/" class="nav-logo">
  59. <img src="../_static/py.svg" alt="Python logo"/>
  60. </a>
  61. <span class="version_switcher_placeholder"></span>
  62. <form role="search" class="search" action="../search.html" method="get">
  63. <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
  64. <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
  65. </svg>
  66. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  67. <input type="submit" value="Go"/>
  68. </form>
  69. </span>
  70. </nav>
  71. <div class="menu-wrapper">
  72. <nav class="menu" role="navigation" aria-label="main navigation">
  73. <div class="language_switcher_placeholder"></div>
  74. <label class="theme-selector-label">
  75. Theme
  76. <select class="theme-selector" oninput="activateTheme(this.value)">
  77. <option value="auto" selected>Auto</option>
  78. <option value="light">Light</option>
  79. <option value="dark">Dark</option>
  80. </select>
  81. </label>
  82. <div>
  83. <h3><a href="../contents.html">Table of Contents</a></h3>
  84. <ul>
  85. <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code> — Minimal DOM implementation</a><ul>
  86. <li><a class="reference internal" href="#dom-objects">DOM Objects</a></li>
  87. <li><a class="reference internal" href="#dom-example">DOM Example</a></li>
  88. <li><a class="reference internal" href="#minidom-and-the-dom-standard">minidom and the DOM standard</a></li>
  89. </ul>
  90. </li>
  91. </ul>
  92. </div>
  93. <div>
  94. <h4>Previous topic</h4>
  95. <p class="topless"><a href="xml.dom.html"
  96. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom</span></code> — The Document Object Model API</a></p>
  97. </div>
  98. <div>
  99. <h4>Next topic</h4>
  100. <p class="topless"><a href="xml.dom.pulldom.html"
  101. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.pulldom</span></code> — Support for building partial DOM trees</a></p>
  102. </div>
  103. <div role="note" aria-label="source link">
  104. <h3>This Page</h3>
  105. <ul class="this-page-menu">
  106. <li><a href="../bugs.html">Report a Bug</a></li>
  107. <li>
  108. <a href="https://github.com/python/cpython/blob/main/Doc/library/xml.dom.minidom.rst"
  109. rel="nofollow">Show Source
  110. </a>
  111. </li>
  112. </ul>
  113. </div>
  114. </nav>
  115. </div>
  116. </div>
  117. <div class="related" role="navigation" aria-label="related navigation">
  118. <h3>Navigation</h3>
  119. <ul>
  120. <li class="right" style="margin-right: 10px">
  121. <a href="../genindex.html" title="General Index"
  122. accesskey="I">index</a></li>
  123. <li class="right" >
  124. <a href="../py-modindex.html" title="Python Module Index"
  125. >modules</a> |</li>
  126. <li class="right" >
  127. <a href="xml.dom.pulldom.html" title="xml.dom.pulldom — Support for building partial DOM trees"
  128. accesskey="N">next</a> |</li>
  129. <li class="right" >
  130. <a href="xml.dom.html" title="xml.dom — The Document Object Model API"
  131. accesskey="P">previous</a> |</li>
  132. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  133. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  134. <li class="switchers">
  135. <div class="language_switcher_placeholder"></div>
  136. <div class="version_switcher_placeholder"></div>
  137. </li>
  138. <li>
  139. </li>
  140. <li id="cpython-language-and-version">
  141. <a href="../index.html">3.12.3 Documentation</a> &#187;
  142. </li>
  143. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  144. <li class="nav-item nav-item-2"><a href="markup.html" accesskey="U">Structured Markup Processing Tools</a> &#187;</li>
  145. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code> — Minimal DOM implementation</a></li>
  146. <li class="right">
  147. <div class="inline-search" role="search">
  148. <form class="inline-search" action="../search.html" method="get">
  149. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  150. <input type="submit" value="Go" />
  151. </form>
  152. </div>
  153. |
  154. </li>
  155. <li class="right">
  156. <label class="theme-selector-label">
  157. Theme
  158. <select class="theme-selector" oninput="activateTheme(this.value)">
  159. <option value="auto" selected>Auto</option>
  160. <option value="light">Light</option>
  161. <option value="dark">Dark</option>
  162. </select>
  163. </label> |</li>
  164. </ul>
  165. </div>
  166. <div class="document">
  167. <div class="documentwrapper">
  168. <div class="bodywrapper">
  169. <div class="body" role="main">
  170. <section id="module-xml.dom.minidom">
  171. <span id="xml-dom-minidom-minimal-dom-implementation"></span><h1><a class="reference internal" href="#module-xml.dom.minidom" title="xml.dom.minidom: Minimal Document Object Model (DOM) implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code></a> — Minimal DOM implementation<a class="headerlink" href="#module-xml.dom.minidom" title="Link to this heading">¶</a></h1>
  172. <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/xml/dom/minidom.py">Lib/xml/dom/minidom.py</a></p>
  173. <hr class="docutils" />
  174. <p><a class="reference internal" href="#module-xml.dom.minidom" title="xml.dom.minidom: Minimal Document Object Model (DOM) implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code></a> is a minimal implementation of the Document Object
  175. Model interface, with an API similar to that in other languages. It is intended
  176. to be simpler than the full DOM and also significantly smaller. Users who are
  177. not already proficient with the DOM should consider using the
  178. <a class="reference internal" href="xml.etree.elementtree.html#module-xml.etree.ElementTree" title="xml.etree.ElementTree: Implementation of the ElementTree API."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.etree.ElementTree</span></code></a> module for their XML processing instead.</p>
  179. <div class="admonition warning">
  180. <p class="admonition-title">Warning</p>
  181. <p>The <a class="reference internal" href="#module-xml.dom.minidom" title="xml.dom.minidom: Minimal Document Object Model (DOM) implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code></a> module is not secure against
  182. maliciously constructed data. If you need to parse untrusted or
  183. unauthenticated data see <a class="reference internal" href="xml.html#xml-vulnerabilities"><span class="std std-ref">XML vulnerabilities</span></a>.</p>
  184. </div>
  185. <p>DOM applications typically start by parsing some XML into a DOM. With
  186. <a class="reference internal" href="#module-xml.dom.minidom" title="xml.dom.minidom: Minimal Document Object Model (DOM) implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code></a>, this is done through the parse functions:</p>
  187. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">xml.dom.minidom</span> <span class="kn">import</span> <span class="n">parse</span><span class="p">,</span> <span class="n">parseString</span>
  188. <span class="n">dom1</span> <span class="o">=</span> <span class="n">parse</span><span class="p">(</span><span class="s1">&#39;c:</span><span class="se">\\</span><span class="s1">temp</span><span class="se">\\</span><span class="s1">mydata.xml&#39;</span><span class="p">)</span> <span class="c1"># parse an XML file by name</span>
  189. <span class="n">datasource</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="s1">&#39;c:</span><span class="se">\\</span><span class="s1">temp</span><span class="se">\\</span><span class="s1">mydata.xml&#39;</span><span class="p">)</span>
  190. <span class="n">dom2</span> <span class="o">=</span> <span class="n">parse</span><span class="p">(</span><span class="n">datasource</span><span class="p">)</span> <span class="c1"># parse an open file</span>
  191. <span class="n">dom3</span> <span class="o">=</span> <span class="n">parseString</span><span class="p">(</span><span class="s1">&#39;&lt;myxml&gt;Some data&lt;empty/&gt; some more data&lt;/myxml&gt;&#39;</span><span class="p">)</span>
  192. </pre></div>
  193. </div>
  194. <p>The <a class="reference internal" href="#xml.dom.minidom.parse" title="xml.dom.minidom.parse"><code class="xref py py-func docutils literal notranslate"><span class="pre">parse()</span></code></a> function can take either a filename or an open file object.</p>
  195. <dl class="py function">
  196. <dt class="sig sig-object py" id="xml.dom.minidom.parse">
  197. <span class="sig-prename descclassname"><span class="pre">xml.dom.minidom.</span></span><span class="sig-name descname"><span class="pre">parse</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename_or_file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parser</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bufsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.minidom.parse" title="Link to this definition">¶</a></dt>
  198. <dd><p>Return a <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> from the given input. <em>filename_or_file</em> may be
  199. either a file name, or a file-like object. <em>parser</em>, if given, must be a SAX2
  200. parser object. This function will change the document handler of the parser and
  201. activate namespace support; other parser configuration (like setting an entity
  202. resolver) must have been done in advance.</p>
  203. </dd></dl>
  204. <p>If you have XML in a string, you can use the <a class="reference internal" href="#xml.dom.minidom.parseString" title="xml.dom.minidom.parseString"><code class="xref py py-func docutils literal notranslate"><span class="pre">parseString()</span></code></a> function
  205. instead:</p>
  206. <dl class="py function">
  207. <dt class="sig sig-object py" id="xml.dom.minidom.parseString">
  208. <span class="sig-prename descclassname"><span class="pre">xml.dom.minidom.</span></span><span class="sig-name descname"><span class="pre">parseString</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parser</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.minidom.parseString" title="Link to this definition">¶</a></dt>
  209. <dd><p>Return a <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> that represents the <em>string</em>. This method creates an
  210. <a class="reference internal" href="io.html#io.StringIO" title="io.StringIO"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.StringIO</span></code></a> object for the string and passes that on to <a class="reference internal" href="#xml.dom.minidom.parse" title="xml.dom.minidom.parse"><code class="xref py py-func docutils literal notranslate"><span class="pre">parse()</span></code></a>.</p>
  211. </dd></dl>
  212. <p>Both functions return a <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> object representing the content of the
  213. document.</p>
  214. <p>What the <a class="reference internal" href="#xml.dom.minidom.parse" title="xml.dom.minidom.parse"><code class="xref py py-func docutils literal notranslate"><span class="pre">parse()</span></code></a> and <a class="reference internal" href="#xml.dom.minidom.parseString" title="xml.dom.minidom.parseString"><code class="xref py py-func docutils literal notranslate"><span class="pre">parseString()</span></code></a> functions do is connect an XML
  215. parser with a “DOM builder” that can accept parse events from any SAX parser and
  216. convert them into a DOM tree. The name of the functions are perhaps misleading,
  217. but are easy to grasp when learning the interfaces. The parsing of the document
  218. will be completed before these functions return; it’s simply that these
  219. functions do not provide a parser implementation themselves.</p>
  220. <p>You can also create a <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> by calling a method on a “DOM
  221. Implementation” object. You can get this object either by calling the
  222. <code class="xref py py-func docutils literal notranslate"><span class="pre">getDOMImplementation()</span></code> function in the <a class="reference internal" href="xml.dom.html#module-xml.dom" title="xml.dom: Document Object Model API for Python."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom</span></code></a> package or the
  223. <a class="reference internal" href="#module-xml.dom.minidom" title="xml.dom.minidom: Minimal Document Object Model (DOM) implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code></a> module. Once you have a <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code>, you
  224. can add child nodes to it to populate the DOM:</p>
  225. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">xml.dom.minidom</span> <span class="kn">import</span> <span class="n">getDOMImplementation</span>
  226. <span class="n">impl</span> <span class="o">=</span> <span class="n">getDOMImplementation</span><span class="p">()</span>
  227. <span class="n">newdoc</span> <span class="o">=</span> <span class="n">impl</span><span class="o">.</span><span class="n">createDocument</span><span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="s2">&quot;some_tag&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
  228. <span class="n">top_element</span> <span class="o">=</span> <span class="n">newdoc</span><span class="o">.</span><span class="n">documentElement</span>
  229. <span class="n">text</span> <span class="o">=</span> <span class="n">newdoc</span><span class="o">.</span><span class="n">createTextNode</span><span class="p">(</span><span class="s1">&#39;Some textual content.&#39;</span><span class="p">)</span>
  230. <span class="n">top_element</span><span class="o">.</span><span class="n">appendChild</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>
  231. </pre></div>
  232. </div>
  233. <p>Once you have a DOM document object, you can access the parts of your XML
  234. document through its properties and methods. These properties are defined in
  235. the DOM specification. The main property of the document object is the
  236. <code class="xref py py-attr docutils literal notranslate"><span class="pre">documentElement</span></code> property. It gives you the main element in the XML
  237. document: the one that holds all others. Here is an example program:</p>
  238. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">dom3</span> <span class="o">=</span> <span class="n">parseString</span><span class="p">(</span><span class="s2">&quot;&lt;myxml&gt;Some data&lt;/myxml&gt;&quot;</span><span class="p">)</span>
  239. <span class="k">assert</span> <span class="n">dom3</span><span class="o">.</span><span class="n">documentElement</span><span class="o">.</span><span class="n">tagName</span> <span class="o">==</span> <span class="s2">&quot;myxml&quot;</span>
  240. </pre></div>
  241. </div>
  242. <p>When you are finished with a DOM tree, you may optionally call the
  243. <code class="xref py py-meth docutils literal notranslate"><span class="pre">unlink()</span></code> method to encourage early cleanup of the now-unneeded
  244. objects. <code class="xref py py-meth docutils literal notranslate"><span class="pre">unlink()</span></code> is an <a class="reference internal" href="#module-xml.dom.minidom" title="xml.dom.minidom: Minimal Document Object Model (DOM) implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code></a>-specific
  245. extension to the DOM API that renders the node and its descendants
  246. essentially useless. Otherwise, Python’s garbage collector will
  247. eventually take care of the objects in the tree.</p>
  248. <div class="admonition seealso">
  249. <p class="admonition-title">See also</p>
  250. <dl class="simple">
  251. <dt><a class="reference external" href="https://www.w3.org/TR/REC-DOM-Level-1/">Document Object Model (DOM) Level 1 Specification</a></dt><dd><p>The W3C recommendation for the DOM supported by <a class="reference internal" href="#module-xml.dom.minidom" title="xml.dom.minidom: Minimal Document Object Model (DOM) implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code></a>.</p>
  252. </dd>
  253. </dl>
  254. </div>
  255. <section id="dom-objects">
  256. <span id="minidom-objects"></span><h2>DOM Objects<a class="headerlink" href="#dom-objects" title="Link to this heading">¶</a></h2>
  257. <p>The definition of the DOM API for Python is given as part of the <a class="reference internal" href="xml.dom.html#module-xml.dom" title="xml.dom: Document Object Model API for Python."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom</span></code></a>
  258. module documentation. This section lists the differences between the API and
  259. <a class="reference internal" href="#module-xml.dom.minidom" title="xml.dom.minidom: Minimal Document Object Model (DOM) implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code></a>.</p>
  260. <dl class="py method">
  261. <dt class="sig sig-object py" id="xml.dom.minidom.Node.unlink">
  262. <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">unlink</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.minidom.Node.unlink" title="Link to this definition">¶</a></dt>
  263. <dd><p>Break internal references within the DOM so that it will be garbage collected on
  264. versions of Python without cyclic GC. Even when cyclic GC is available, using
  265. this can make large amounts of memory available sooner, so calling this on DOM
  266. objects as soon as they are no longer needed is good practice. This only needs
  267. to be called on the <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> object, but may be called on child nodes
  268. to discard children of that node.</p>
  269. <p>You can avoid calling this method explicitly by using the <a class="reference internal" href="../reference/compound_stmts.html#with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code></a>
  270. statement. The following code will automatically unlink <em>dom</em> when the
  271. <code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code> block is exited:</p>
  272. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">with</span> <span class="n">xml</span><span class="o">.</span><span class="n">dom</span><span class="o">.</span><span class="n">minidom</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">datasource</span><span class="p">)</span> <span class="k">as</span> <span class="n">dom</span><span class="p">:</span>
  273. <span class="o">...</span> <span class="c1"># Work with dom.</span>
  274. </pre></div>
  275. </div>
  276. </dd></dl>
  277. <dl class="py method">
  278. <dt class="sig sig-object py" id="xml.dom.minidom.Node.writexml">
  279. <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">writexml</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">writer</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indent</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">addindent</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newl</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">encoding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">standalone</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.minidom.Node.writexml" title="Link to this definition">¶</a></dt>
  280. <dd><p>Write XML to the writer object. The writer receives texts but not bytes as input,
  281. it should have a <code class="xref py py-meth docutils literal notranslate"><span class="pre">write()</span></code> method which matches that of the file object
  282. interface. The <em>indent</em> parameter is the indentation of the current node.
  283. The <em>addindent</em> parameter is the incremental indentation to use for subnodes
  284. of the current one. The <em>newl</em> parameter specifies the string to use to
  285. terminate newlines.</p>
  286. <p>For the <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> node, an additional keyword argument <em>encoding</em> can
  287. be used to specify the encoding field of the XML header.</p>
  288. <p>Similarly, explicitly stating the <em>standalone</em> argument causes the
  289. standalone document declarations to be added to the prologue of the XML
  290. document.
  291. If the value is set to <code class="docutils literal notranslate"><span class="pre">True</span></code>, <code class="docutils literal notranslate"><span class="pre">standalone=&quot;yes&quot;</span></code> is added,
  292. otherwise it is set to <code class="docutils literal notranslate"><span class="pre">&quot;no&quot;</span></code>.
  293. Not stating the argument will omit the declaration from the document.</p>
  294. <div class="versionchanged">
  295. <p><span class="versionmodified changed">Changed in version 3.8: </span>The <a class="reference internal" href="#xml.dom.minidom.Node.writexml" title="xml.dom.minidom.Node.writexml"><code class="xref py py-meth docutils literal notranslate"><span class="pre">writexml()</span></code></a> method now preserves the attribute order specified
  296. by the user.</p>
  297. </div>
  298. <div class="versionchanged">
  299. <p><span class="versionmodified changed">Changed in version 3.9: </span>The <em>standalone</em> parameter was added.</p>
  300. </div>
  301. </dd></dl>
  302. <dl class="py method">
  303. <dt class="sig sig-object py" id="xml.dom.minidom.Node.toxml">
  304. <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">toxml</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">encoding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">standalone</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.minidom.Node.toxml" title="Link to this definition">¶</a></dt>
  305. <dd><p>Return a string or byte string containing the XML represented by
  306. the DOM node.</p>
  307. <p>With an explicit <em>encoding</em> <a class="footnote-reference brackets" href="#id3" id="id1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a> argument, the result is a byte
  308. string in the specified encoding.
  309. With no <em>encoding</em> argument, the result is a Unicode string, and the
  310. XML declaration in the resulting string does not specify an
  311. encoding. Encoding this string in an encoding other than UTF-8 is
  312. likely incorrect, since UTF-8 is the default encoding of XML.</p>
  313. <p>The <em>standalone</em> argument behaves exactly as in <a class="reference internal" href="#xml.dom.minidom.Node.writexml" title="xml.dom.minidom.Node.writexml"><code class="xref py py-meth docutils literal notranslate"><span class="pre">writexml()</span></code></a>.</p>
  314. <div class="versionchanged">
  315. <p><span class="versionmodified changed">Changed in version 3.8: </span>The <a class="reference internal" href="#xml.dom.minidom.Node.toxml" title="xml.dom.minidom.Node.toxml"><code class="xref py py-meth docutils literal notranslate"><span class="pre">toxml()</span></code></a> method now preserves the attribute order specified
  316. by the user.</p>
  317. </div>
  318. <div class="versionchanged">
  319. <p><span class="versionmodified changed">Changed in version 3.9: </span>The <em>standalone</em> parameter was added.</p>
  320. </div>
  321. </dd></dl>
  322. <dl class="py method">
  323. <dt class="sig sig-object py" id="xml.dom.minidom.Node.toprettyxml">
  324. <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">toprettyxml</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">indent</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'\t'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newl</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'\n'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">encoding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">standalone</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.minidom.Node.toprettyxml" title="Link to this definition">¶</a></dt>
  325. <dd><p>Return a pretty-printed version of the document. <em>indent</em> specifies the
  326. indentation string and defaults to a tabulator; <em>newl</em> specifies the string
  327. emitted at the end of each line and defaults to <code class="docutils literal notranslate"><span class="pre">\n</span></code>.</p>
  328. <p>The <em>encoding</em> argument behaves like the corresponding argument of
  329. <a class="reference internal" href="#xml.dom.minidom.Node.toxml" title="xml.dom.minidom.Node.toxml"><code class="xref py py-meth docutils literal notranslate"><span class="pre">toxml()</span></code></a>.</p>
  330. <p>The <em>standalone</em> argument behaves exactly as in <a class="reference internal" href="#xml.dom.minidom.Node.writexml" title="xml.dom.minidom.Node.writexml"><code class="xref py py-meth docutils literal notranslate"><span class="pre">writexml()</span></code></a>.</p>
  331. <div class="versionchanged">
  332. <p><span class="versionmodified changed">Changed in version 3.8: </span>The <a class="reference internal" href="#xml.dom.minidom.Node.toprettyxml" title="xml.dom.minidom.Node.toprettyxml"><code class="xref py py-meth docutils literal notranslate"><span class="pre">toprettyxml()</span></code></a> method now preserves the attribute order specified
  333. by the user.</p>
  334. </div>
  335. <div class="versionchanged">
  336. <p><span class="versionmodified changed">Changed in version 3.9: </span>The <em>standalone</em> parameter was added.</p>
  337. </div>
  338. </dd></dl>
  339. </section>
  340. <section id="dom-example">
  341. <span id="id2"></span><h2>DOM Example<a class="headerlink" href="#dom-example" title="Link to this heading">¶</a></h2>
  342. <p>This example program is a fairly realistic example of a simple program. In this
  343. particular case, we do not take much advantage of the flexibility of the DOM.</p>
  344. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">xml.dom.minidom</span>
  345. <span class="n">document</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;</span><span class="se">\</span>
  346. <span class="s2">&lt;slideshow&gt;</span>
  347. <span class="s2">&lt;title&gt;Demo slideshow&lt;/title&gt;</span>
  348. <span class="s2">&lt;slide&gt;&lt;title&gt;Slide title&lt;/title&gt;</span>
  349. <span class="s2">&lt;point&gt;This is a demo&lt;/point&gt;</span>
  350. <span class="s2">&lt;point&gt;Of a program for processing slides&lt;/point&gt;</span>
  351. <span class="s2">&lt;/slide&gt;</span>
  352. <span class="s2">&lt;slide&gt;&lt;title&gt;Another demo slide&lt;/title&gt;</span>
  353. <span class="s2">&lt;point&gt;It is important&lt;/point&gt;</span>
  354. <span class="s2">&lt;point&gt;To have more than&lt;/point&gt;</span>
  355. <span class="s2">&lt;point&gt;one slide&lt;/point&gt;</span>
  356. <span class="s2">&lt;/slide&gt;</span>
  357. <span class="s2">&lt;/slideshow&gt;</span>
  358. <span class="s2">&quot;&quot;&quot;</span>
  359. <span class="n">dom</span> <span class="o">=</span> <span class="n">xml</span><span class="o">.</span><span class="n">dom</span><span class="o">.</span><span class="n">minidom</span><span class="o">.</span><span class="n">parseString</span><span class="p">(</span><span class="n">document</span><span class="p">)</span>
  360. <span class="k">def</span> <span class="nf">getText</span><span class="p">(</span><span class="n">nodelist</span><span class="p">):</span>
  361. <span class="n">rc</span> <span class="o">=</span> <span class="p">[]</span>
  362. <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">nodelist</span><span class="p">:</span>
  363. <span class="k">if</span> <span class="n">node</span><span class="o">.</span><span class="n">nodeType</span> <span class="o">==</span> <span class="n">node</span><span class="o">.</span><span class="n">TEXT_NODE</span><span class="p">:</span>
  364. <span class="n">rc</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">data</span><span class="p">)</span>
  365. <span class="k">return</span> <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">rc</span><span class="p">)</span>
  366. <span class="k">def</span> <span class="nf">handleSlideshow</span><span class="p">(</span><span class="n">slideshow</span><span class="p">):</span>
  367. <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&lt;html&gt;&quot;</span><span class="p">)</span>
  368. <span class="n">handleSlideshowTitle</span><span class="p">(</span><span class="n">slideshow</span><span class="o">.</span><span class="n">getElementsByTagName</span><span class="p">(</span><span class="s2">&quot;title&quot;</span><span class="p">)[</span><span class="mi">0</span><span class="p">])</span>
  369. <span class="n">slides</span> <span class="o">=</span> <span class="n">slideshow</span><span class="o">.</span><span class="n">getElementsByTagName</span><span class="p">(</span><span class="s2">&quot;slide&quot;</span><span class="p">)</span>
  370. <span class="n">handleToc</span><span class="p">(</span><span class="n">slides</span><span class="p">)</span>
  371. <span class="n">handleSlides</span><span class="p">(</span><span class="n">slides</span><span class="p">)</span>
  372. <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&lt;/html&gt;&quot;</span><span class="p">)</span>
  373. <span class="k">def</span> <span class="nf">handleSlides</span><span class="p">(</span><span class="n">slides</span><span class="p">):</span>
  374. <span class="k">for</span> <span class="n">slide</span> <span class="ow">in</span> <span class="n">slides</span><span class="p">:</span>
  375. <span class="n">handleSlide</span><span class="p">(</span><span class="n">slide</span><span class="p">)</span>
  376. <span class="k">def</span> <span class="nf">handleSlide</span><span class="p">(</span><span class="n">slide</span><span class="p">):</span>
  377. <span class="n">handleSlideTitle</span><span class="p">(</span><span class="n">slide</span><span class="o">.</span><span class="n">getElementsByTagName</span><span class="p">(</span><span class="s2">&quot;title&quot;</span><span class="p">)[</span><span class="mi">0</span><span class="p">])</span>
  378. <span class="n">handlePoints</span><span class="p">(</span><span class="n">slide</span><span class="o">.</span><span class="n">getElementsByTagName</span><span class="p">(</span><span class="s2">&quot;point&quot;</span><span class="p">))</span>
  379. <span class="k">def</span> <span class="nf">handleSlideshowTitle</span><span class="p">(</span><span class="n">title</span><span class="p">):</span>
  380. <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;&lt;title&gt;</span><span class="si">{</span><span class="n">getText</span><span class="p">(</span><span class="n">title</span><span class="o">.</span><span class="n">childNodes</span><span class="p">)</span><span class="si">}</span><span class="s2">&lt;/title&gt;&quot;</span><span class="p">)</span>
  381. <span class="k">def</span> <span class="nf">handleSlideTitle</span><span class="p">(</span><span class="n">title</span><span class="p">):</span>
  382. <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;&lt;h2&gt;</span><span class="si">{</span><span class="n">getText</span><span class="p">(</span><span class="n">title</span><span class="o">.</span><span class="n">childNodes</span><span class="p">)</span><span class="si">}</span><span class="s2">&lt;/h2&gt;&quot;</span><span class="p">)</span>
  383. <span class="k">def</span> <span class="nf">handlePoints</span><span class="p">(</span><span class="n">points</span><span class="p">):</span>
  384. <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&lt;ul&gt;&quot;</span><span class="p">)</span>
  385. <span class="k">for</span> <span class="n">point</span> <span class="ow">in</span> <span class="n">points</span><span class="p">:</span>
  386. <span class="n">handlePoint</span><span class="p">(</span><span class="n">point</span><span class="p">)</span>
  387. <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&lt;/ul&gt;&quot;</span><span class="p">)</span>
  388. <span class="k">def</span> <span class="nf">handlePoint</span><span class="p">(</span><span class="n">point</span><span class="p">):</span>
  389. <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;&lt;li&gt;</span><span class="si">{</span><span class="n">getText</span><span class="p">(</span><span class="n">point</span><span class="o">.</span><span class="n">childNodes</span><span class="p">)</span><span class="si">}</span><span class="s2">&lt;/li&gt;&quot;</span><span class="p">)</span>
  390. <span class="k">def</span> <span class="nf">handleToc</span><span class="p">(</span><span class="n">slides</span><span class="p">):</span>
  391. <span class="k">for</span> <span class="n">slide</span> <span class="ow">in</span> <span class="n">slides</span><span class="p">:</span>
  392. <span class="n">title</span> <span class="o">=</span> <span class="n">slide</span><span class="o">.</span><span class="n">getElementsByTagName</span><span class="p">(</span><span class="s2">&quot;title&quot;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
  393. <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;&lt;p&gt;</span><span class="si">{</span><span class="n">getText</span><span class="p">(</span><span class="n">title</span><span class="o">.</span><span class="n">childNodes</span><span class="p">)</span><span class="si">}</span><span class="s2">&lt;/p&gt;&quot;</span><span class="p">)</span>
  394. <span class="n">handleSlideshow</span><span class="p">(</span><span class="n">dom</span><span class="p">)</span>
  395. </pre></div>
  396. </div>
  397. </section>
  398. <section id="minidom-and-the-dom-standard">
  399. <span id="minidom-and-dom"></span><h2>minidom and the DOM standard<a class="headerlink" href="#minidom-and-the-dom-standard" title="Link to this heading">¶</a></h2>
  400. <p>The <a class="reference internal" href="#module-xml.dom.minidom" title="xml.dom.minidom: Minimal Document Object Model (DOM) implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code></a> module is essentially a DOM 1.0-compatible DOM with
  401. some DOM 2 features (primarily namespace features).</p>
  402. <p>Usage of the DOM interface in Python is straight-forward. The following mapping
  403. rules apply:</p>
  404. <ul class="simple">
  405. <li><p>Interfaces are accessed through instance objects. Applications should not
  406. instantiate the classes themselves; they should use the creator functions
  407. available on the <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> object. Derived interfaces support all
  408. operations (and attributes) from the base interfaces, plus any new operations.</p></li>
  409. <li><p>Operations are used as methods. Since the DOM uses only <a class="reference internal" href="../reference/expressions.html#in"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">in</span></code></a>
  410. parameters, the arguments are passed in normal order (from left to right).
  411. There are no optional arguments. <code class="docutils literal notranslate"><span class="pre">void</span></code> operations return <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p></li>
  412. <li><p>IDL attributes map to instance attributes. For compatibility with the OMG IDL
  413. language mapping for Python, an attribute <code class="docutils literal notranslate"><span class="pre">foo</span></code> can also be accessed through
  414. accessor methods <code class="xref py py-meth docutils literal notranslate"><span class="pre">_get_foo()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">_set_foo()</span></code>. <code class="docutils literal notranslate"><span class="pre">readonly</span></code>
  415. attributes must not be changed; this is not enforced at runtime.</p></li>
  416. <li><p>The types <code class="docutils literal notranslate"><span class="pre">short</span> <span class="pre">int</span></code>, <code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">int</span></code>, <code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">long</span></code>, and
  417. <code class="docutils literal notranslate"><span class="pre">boolean</span></code> all map to Python integer objects.</p></li>
  418. <li><p>The type <code class="docutils literal notranslate"><span class="pre">DOMString</span></code> maps to Python strings. <a class="reference internal" href="#module-xml.dom.minidom" title="xml.dom.minidom: Minimal Document Object Model (DOM) implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code></a> supports
  419. either bytes or strings, but will normally produce strings.
  420. Values of type <code class="docutils literal notranslate"><span class="pre">DOMString</span></code> may also be <code class="docutils literal notranslate"><span class="pre">None</span></code> where allowed to have the IDL
  421. <code class="docutils literal notranslate"><span class="pre">null</span></code> value by the DOM specification from the W3C.</p></li>
  422. <li><p><code class="docutils literal notranslate"><span class="pre">const</span></code> declarations map to variables in their respective scope (e.g.
  423. <code class="docutils literal notranslate"><span class="pre">xml.dom.minidom.Node.PROCESSING_INSTRUCTION_NODE</span></code>); they must not be changed.</p></li>
  424. <li><p><code class="docutils literal notranslate"><span class="pre">DOMException</span></code> is currently not supported in <a class="reference internal" href="#module-xml.dom.minidom" title="xml.dom.minidom: Minimal Document Object Model (DOM) implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code></a>.
  425. Instead, <a class="reference internal" href="#module-xml.dom.minidom" title="xml.dom.minidom: Minimal Document Object Model (DOM) implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code></a> uses standard Python exceptions such as
  426. <a class="reference internal" href="exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> and <a class="reference internal" href="exceptions.html#AttributeError" title="AttributeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">AttributeError</span></code></a>.</p></li>
  427. <li><p><code class="xref py py-class docutils literal notranslate"><span class="pre">NodeList</span></code> objects are implemented using Python’s built-in list type.
  428. These objects provide the interface defined in the DOM specification, but with
  429. earlier versions of Python they do not support the official API. They are,
  430. however, much more “Pythonic” than the interface defined in the W3C
  431. recommendations.</p></li>
  432. </ul>
  433. <p>The following interfaces have no implementation in <a class="reference internal" href="#module-xml.dom.minidom" title="xml.dom.minidom: Minimal Document Object Model (DOM) implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code></a>:</p>
  434. <ul class="simple">
  435. <li><p><code class="xref py py-class docutils literal notranslate"><span class="pre">DOMTimeStamp</span></code></p></li>
  436. <li><p><code class="xref py py-class docutils literal notranslate"><span class="pre">EntityReference</span></code></p></li>
  437. </ul>
  438. <p>Most of these reflect information in the XML document that is not of general
  439. utility to most DOM users.</p>
  440. <p class="rubric">Footnotes</p>
  441. <aside class="footnote-list brackets">
  442. <aside class="footnote brackets" id="id3" role="doc-footnote">
  443. <span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id1">1</a><span class="fn-bracket">]</span></span>
  444. <p>The encoding name included in the XML output should conform to
  445. the appropriate standards. For example, “UTF-8” is valid, but
  446. “UTF8” is not valid in an XML document’s declaration, even though
  447. Python accepts it as an encoding name.
  448. See <a class="reference external" href="https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl">https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl</a>
  449. and <a class="reference external" href="https://www.iana.org/assignments/character-sets/character-sets.xhtml">https://www.iana.org/assignments/character-sets/character-sets.xhtml</a>.</p>
  450. </aside>
  451. </aside>
  452. </section>
  453. </section>
  454. <div class="clearer"></div>
  455. </div>
  456. </div>
  457. </div>
  458. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  459. <div class="sphinxsidebarwrapper">
  460. <div>
  461. <h3><a href="../contents.html">Table of Contents</a></h3>
  462. <ul>
  463. <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code> — Minimal DOM implementation</a><ul>
  464. <li><a class="reference internal" href="#dom-objects">DOM Objects</a></li>
  465. <li><a class="reference internal" href="#dom-example">DOM Example</a></li>
  466. <li><a class="reference internal" href="#minidom-and-the-dom-standard">minidom and the DOM standard</a></li>
  467. </ul>
  468. </li>
  469. </ul>
  470. </div>
  471. <div>
  472. <h4>Previous topic</h4>
  473. <p class="topless"><a href="xml.dom.html"
  474. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom</span></code> — The Document Object Model API</a></p>
  475. </div>
  476. <div>
  477. <h4>Next topic</h4>
  478. <p class="topless"><a href="xml.dom.pulldom.html"
  479. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.pulldom</span></code> — Support for building partial DOM trees</a></p>
  480. </div>
  481. <div role="note" aria-label="source link">
  482. <h3>This Page</h3>
  483. <ul class="this-page-menu">
  484. <li><a href="../bugs.html">Report a Bug</a></li>
  485. <li>
  486. <a href="https://github.com/python/cpython/blob/main/Doc/library/xml.dom.minidom.rst"
  487. rel="nofollow">Show Source
  488. </a>
  489. </li>
  490. </ul>
  491. </div>
  492. </div>
  493. <div id="sidebarbutton" title="Collapse sidebar">
  494. <span>«</span>
  495. </div>
  496. </div>
  497. <div class="clearer"></div>
  498. </div>
  499. <div class="related" role="navigation" aria-label="related navigation">
  500. <h3>Navigation</h3>
  501. <ul>
  502. <li class="right" style="margin-right: 10px">
  503. <a href="../genindex.html" title="General Index"
  504. >index</a></li>
  505. <li class="right" >
  506. <a href="../py-modindex.html" title="Python Module Index"
  507. >modules</a> |</li>
  508. <li class="right" >
  509. <a href="xml.dom.pulldom.html" title="xml.dom.pulldom — Support for building partial DOM trees"
  510. >next</a> |</li>
  511. <li class="right" >
  512. <a href="xml.dom.html" title="xml.dom — The Document Object Model API"
  513. >previous</a> |</li>
  514. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  515. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  516. <li class="switchers">
  517. <div class="language_switcher_placeholder"></div>
  518. <div class="version_switcher_placeholder"></div>
  519. </li>
  520. <li>
  521. </li>
  522. <li id="cpython-language-and-version">
  523. <a href="../index.html">3.12.3 Documentation</a> &#187;
  524. </li>
  525. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  526. <li class="nav-item nav-item-2"><a href="markup.html" >Structured Markup Processing Tools</a> &#187;</li>
  527. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code> — Minimal DOM implementation</a></li>
  528. <li class="right">
  529. <div class="inline-search" role="search">
  530. <form class="inline-search" action="../search.html" method="get">
  531. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  532. <input type="submit" value="Go" />
  533. </form>
  534. </div>
  535. |
  536. </li>
  537. <li class="right">
  538. <label class="theme-selector-label">
  539. Theme
  540. <select class="theme-selector" oninput="activateTheme(this.value)">
  541. <option value="auto" selected>Auto</option>
  542. <option value="light">Light</option>
  543. <option value="dark">Dark</option>
  544. </select>
  545. </label> |</li>
  546. </ul>
  547. </div>
  548. <div class="footer">
  549. &copy;
  550. <a href="../copyright.html">
  551. Copyright
  552. </a>
  553. 2001-2024, Python Software Foundation.
  554. <br />
  555. This page is licensed under the Python Software Foundation License Version 2.
  556. <br />
  557. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  558. <br />
  559. See <a href="/license.html">History and License</a> for more information.<br />
  560. <br />
  561. The Python Software Foundation is a non-profit corporation.
  562. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  563. <br />
  564. <br />
  565. Last updated on Apr 09, 2024 (13:47 UTC).
  566. <a href="/bugs.html">Found a bug</a>?
  567. <br />
  568. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  569. </div>
  570. </body>
  571. </html>
上海开阖软件有限公司 沪ICP备12045867号-1