Team Ai
Apppublic

parthtamu/rag-code-assistant

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
xml.dom.minidom.html673 linesDownload Raw Back to docs
1<!DOCTYPE html>2 3<html lang="en" data-content_root="../">4  <head>5    <meta charset="utf-8" />6    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />7<meta property="og:title" content="xml.dom.minidom — Minimal DOM implementation" />8<meta property="og:type" content="website" />9<meta property="og:url" content="https://docs.python.org/3/library/xml.dom.minidom.html" />10<meta property="og:site_name" content="Python documentation" />11<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 ..." />12<meta property="og:image:width" content="1146" />13<meta property="og:image:height" content="600" />14<meta property="og:image" content="https://docs.python.org/3.15/_images/social_previews/summary_library_xml.dom.minidom_ce38122f.png" />15<meta property="og:image:alt" 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 ..." />16<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 ..." />17<meta name="twitter:card" content="summary_large_image" />18<meta name="theme-color" content="#3776ab">19 20    <title>xml.dom.minidom — Minimal DOM implementation &#8212; Python 3.15.0a6 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">21    22    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />23    <link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />24    <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=89a2f22a" />25    <link rel="stylesheet" type="text/css" href="../_static/profiling-sampling-visualization.css?v=0c2600ae" />26    <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" />27    28    <script src="../_static/documentation_options.js?v=6b7c9ff5"></script>29    <script src="../_static/doctools.js?v=9bcbadda"></script>30    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>31    <script src="../_static/profiling-sampling-visualization.js?v=9811ed04"></script>32    33    <script src="../_static/sidebar.js"></script>34    35    <link rel="search" type="application/opensearchdescription+xml"36          title="Search within Python 3.15.0a6 documentation"37          href="../_static/opensearch.xml"/>38    <link rel="author" title="About these documents" href="../about.html" />39    <link rel="index" title="Index" href="../genindex.html" />40    <link rel="search" title="Search" href="../search.html" />41    <link rel="copyright" title="Copyright" href="../copyright.html" />42    <link rel="next" title="xml.dom.pulldom — Support for building partial DOM trees" href="xml.dom.pulldom.html" />43    <link rel="prev" title="xml.dom — The Document Object Model API" href="xml.dom.html" />44    45      46      <script defer file-types="bz2,epub,zip" data-domain="docs.python.org" src="https://analytics.python.org/js/script.file-downloads.outbound-links.js"></script>47      48      <link rel="canonical" href="https://docs.python.org/3/library/xml.dom.minidom.html">49      50    51 52    53    <style>54      @media only screen {55        table.full-width-table {56            width: 100%;57        }58      }59    </style>60<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">61    <link rel="shortcut icon" type="image/png" href="../_static/py.svg">62            <script type="text/javascript" src="../_static/copybutton.js"></script>63            <script type="text/javascript" src="../_static/menu.js"></script>64            <script type="text/javascript" src="../_static/search-focus.js"></script>65            <script type="text/javascript" src="../_static/themetoggle.js"></script> 66            <script type="text/javascript" src="../_static/rtd_switcher.js"></script>67            <meta name="readthedocs-addons-api-version" content="1">68 69  </head>70<body>71<div class="mobile-nav">72    <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"73           aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">74    <nav class="nav-content" role="navigation">75        <label for="menuToggler" class="toggler__label">76            <span></span>77        </label>78        <span class="nav-items-wrapper">79            <a href="https://www.python.org/" class="nav-logo">80                <img src="../_static/py.svg" alt="Python logo">81            </a>82            <span class="version_switcher_placeholder"></span>83            <form role="search" class="search" action="../search.html" method="get">84                <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">85                    <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>86                </svg>87                <input placeholder="Quick search" aria-label="Quick search" type="search" name="q">88                <input type="submit" value="Go">89            </form>90        </span>91    </nav>92    <div class="menu-wrapper">93        <nav class="menu" role="navigation" aria-label="main navigation">94            <div class="language_switcher_placeholder"></div>95            96<label class="theme-selector-label">97    Theme98    <select class="theme-selector" oninput="activateTheme(this.value)">99        <option value="auto" selected>Auto</option>100        <option value="light">Light</option>101        <option value="dark">Dark</option>102    </select>103</label>104  <div>105    <h3><a href="../contents.html">Table of Contents</a></h3>106    <ul>107<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>108<li><a class="reference internal" href="#dom-objects">DOM Objects</a></li>109<li><a class="reference internal" href="#dom-example">DOM Example</a></li>110<li><a class="reference internal" href="#minidom-and-the-dom-standard">minidom and the DOM standard</a></li>111</ul>112</li>113</ul>114 115  </div>116  <div>117    <h4>Previous topic</h4>118    <p class="topless"><a href="xml.dom.html"119                          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>120  </div>121  <div>122    <h4>Next topic</h4>123    <p class="topless"><a href="xml.dom.pulldom.html"124                          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>125  </div>126  <script>127    document.addEventListener('DOMContentLoaded', () => {128        const title = document.querySelector('meta[property="og:title"]').content;129        const elements = document.querySelectorAll('.improvepage');130        const pageurl = window.location.href.split('?')[0];131        elements.forEach(element => {132            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));133            url.searchParams.set('pagetitle', title);134            url.searchParams.set('pageurl', pageurl);135            url.searchParams.set('pagesource', "library/xml.dom.minidom.rst");136            element.href = url.toString();137        });138    });139  </script>140  <div role="note" aria-label="source link">141    <h3>This page</h3>142    <ul class="this-page-menu">143      <li><a href="../bugs.html">Report a bug</a></li>144      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>145      <li>146        <a href="https://github.com/python/cpython/blob/main/Doc/library/xml.dom.minidom.rst?plain=1"147            rel="nofollow">Show source148        </a>149      </li>150      151    </ul>152  </div>153        </nav>154    </div>155</div>156 157  158    <div class="related" role="navigation" aria-label="Related">159      <h3>Navigation</h3>160      <ul>161        <li class="right" style="margin-right: 10px">162          <a href="../genindex.html" title="General Index"163             accesskey="I">index</a></li>164        <li class="right" >165          <a href="../py-modindex.html" title="Python Module Index"166             >modules</a> |</li>167        <li class="right" >168          <a href="xml.dom.pulldom.html" title="xml.dom.pulldom — Support for building partial DOM trees"169             accesskey="N">next</a> |</li>170        <li class="right" >171          <a href="xml.dom.html" title="xml.dom — The Document Object Model API"172             accesskey="P">previous</a> |</li>173 174          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>175          <li><a href="https://www.python.org/">Python</a> &#187;</li>176          <li class="switchers">177            <div class="language_switcher_placeholder"></div>178            <div class="version_switcher_placeholder"></div>179          </li>180          <li>181              182          </li>183    <li id="cpython-language-and-version">184      <a href="../index.html">3.15.0a6 Documentation</a> &#187;185    </li>186 187          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>188          <li class="nav-item nav-item-2"><a href="markup.html" accesskey="U">Structured Markup Processing Tools</a> &#187;</li>189        <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>190                <li class="right">191                    192 193    <div class="inline-search" role="search">194        <form class="inline-search" action="../search.html" method="get">195          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">196          <input type="submit" value="Go">197        </form>198    </div>199                     |200                </li>201            <li class="right">202<label class="theme-selector-label">203    Theme204    <select class="theme-selector" oninput="activateTheme(this.value)">205        <option value="auto" selected>Auto</option>206        <option value="light">Light</option>207        <option value="dark">Dark</option>208    </select>209</label> |</li>210            211      </ul>212    </div>    213 214    <div class="document">215      <div class="documentwrapper">216        <div class="bodywrapper">217          <div class="body" role="main">218            219  <section id="module-xml.dom.minidom">220<span id="xml-dom-minidom-minimal-dom-implementation"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code> — Minimal DOM implementation<a class="headerlink" href="#module-xml.dom.minidom" title="Link to this heading">¶</a></h1>221<p><strong>Source code:</strong> <a class="extlink-source reference external" href="https://github.com/python/cpython/tree/main/Lib/xml/dom/minidom.py">Lib/xml/dom/minidom.py</a></p>222<hr class="docutils" />223<p><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code> is a minimal implementation of the Document Object224Model interface, with an API similar to that in other languages.  It is intended225to be simpler than the full DOM and also significantly smaller.  Users who are226not already proficient with the DOM should consider using the227<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>228<div class="admonition note">229<p class="admonition-title">Note</p>230<p>If you need to parse untrusted or unauthenticated data, see231<a class="reference internal" href="xml.html#xml-security"><span class="std std-ref">XML security</span></a>.</p>232</div>233<p>DOM applications typically start by parsing some XML into a DOM.  With234<code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code>, this is done through the parse functions:</p>235<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">xml.dom.minidom</span><span class="w"> </span><span class="kn">import</span> <span class="n">parse</span><span class="p">,</span> <span class="n">parseString</span>236 237<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>238 239<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>240<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>241 242<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>243</pre></div>244</div>245<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>246<dl class="py function">247<dt class="sig sig-object py" id="xml.dom.minidom.parse">248<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>249<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 be250either a file name, or a file-like object. <em>parser</em>, if given, must be a SAX2251parser object. This function will change the document handler of the parser and252activate namespace support; other parser configuration (like setting an entity253resolver) must have been done in advance.</p>254</dd></dl>255 256<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> function257instead:</p>258<dl class="py function">259<dt class="sig sig-object py" id="xml.dom.minidom.parseString">260<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>261<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 an262<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>263</dd></dl>264 265<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 the266document.</p>267<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 XML268parser with a “DOM builder” that can accept parse events from any SAX parser and269convert them into a DOM tree.  The names of the functions are perhaps misleading,270but are easy to grasp when learning the interfaces.  The parsing of the document271will be completed before these functions return; it’s simply that these272functions do not provide a parser implementation themselves.</p>273<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 “DOM274Implementation” object.  You can get this object either by calling the275<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 the276<code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code> module.  Once you have a <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code>, you277can add child nodes to it to populate the DOM:</p>278<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">xml.dom.minidom</span><span class="w"> </span><span class="kn">import</span> <span class="n">getDOMImplementation</span>279 280<span class="n">impl</span> <span class="o">=</span> <span class="n">getDOMImplementation</span><span class="p">()</span>281 282<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>283<span class="n">top_element</span> <span class="o">=</span> <span class="n">newdoc</span><span class="o">.</span><span class="n">documentElement</span>284<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>285<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>286</pre></div>287</div>288<p>Once you have a DOM document object, you can access the parts of your XML289document through its properties and methods.  These properties are defined in290the DOM specification.  The main property of the document object is the291<code class="xref py py-attr docutils literal notranslate"><span class="pre">documentElement</span></code> property.  It gives you the main element in the XML292document: the one that holds all others.  Here is an example program:</p>293<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>294<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>295</pre></div>296</div>297<p>When you are finished with a DOM tree, you may optionally call the298<code class="xref py py-meth docutils literal notranslate"><span class="pre">unlink()</span></code> method to encourage early cleanup of the now-unneeded299objects.  <code class="xref py py-meth docutils literal notranslate"><span class="pre">unlink()</span></code> is an <code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code>-specific300extension to the DOM API that renders the node and its descendants301essentially useless.  Otherwise, Python’s garbage collector will302eventually take care of the objects in the tree.</p>303<div class="admonition seealso">304<p class="admonition-title">See also</p>305<dl class="simple">306<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 <code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code>.</p>307</dd>308</dl>309</div>310<section id="dom-objects">311<span id="minidom-objects"></span><h2>DOM Objects<a class="headerlink" href="#dom-objects" title="Link to this heading">¶</a></h2>312<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>313module documentation.  This section lists the differences between the API and314<code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code>.</p>315<dl class="py method">316<dt class="sig sig-object py" id="xml.dom.minidom.Node.unlink">317<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>318<dd><p>Break internal references within the DOM so that it will be garbage collected on319versions of Python without cyclic GC.  Even when cyclic GC is available, using320this can make large amounts of memory available sooner, so calling this on DOM321objects as soon as they are no longer needed is good practice.  This only needs322to 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 nodes323to discard children of that node.</p>324<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>325statement. The following code will automatically unlink <em>dom</em> when the326<code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code> block is exited:</p>327<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>328    <span class="o">...</span> <span class="c1"># Work with dom.</span>329</pre></div>330</div>331</dd></dl>332 333<dl class="py method">334<dt class="sig sig-object py" id="xml.dom.minidom.Node.writexml">335<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>336<dd><p>Write XML to the writer object.  The writer receives texts but not bytes as input,337it 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 object338interface.  The <em>indent</em> parameter is the indentation of the current node.339The <em>addindent</em> parameter is the incremental indentation to use for subnodes340of the current one.  The <em>newl</em> parameter specifies the string to use to341terminate newlines.</p>342<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> can343be used to specify the encoding field of the XML header.</p>344<p>Similarly, explicitly stating the <em>standalone</em> argument causes the345standalone document declarations to be added to the prologue of the XML346document.347If 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,348otherwise it is set to <code class="docutils literal notranslate"><span class="pre">&quot;no&quot;</span></code>.349Not stating the argument will omit the declaration from the document.</p>350<div class="versionchanged">351<p><span class="versionmodified changed">Changed in version 3.8: </span>The <code class="xref py py-meth docutils literal notranslate"><span class="pre">writexml()</span></code> method now preserves the attribute order specified352by the user.</p>353</div>354<div class="versionchanged">355<p><span class="versionmodified changed">Changed in version 3.9: </span>The <em>standalone</em> parameter was added.</p>356</div>357</dd></dl>358 359<dl class="py method">360<dt class="sig sig-object py" id="xml.dom.minidom.Node.toxml">361<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>362<dd><p>Return a string or byte string containing the XML represented by363the DOM node.</p>364<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 byte365string in the specified encoding.366With no <em>encoding</em> argument, the result is a Unicode string, and the367XML declaration in the resulting string does not specify an368encoding. Encoding this string in an encoding other than UTF-8 is369likely incorrect, since UTF-8 is the default encoding of XML.</p>370<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>371<div class="versionchanged">372<p><span class="versionmodified changed">Changed in version 3.8: </span>The <code class="xref py py-meth docutils literal notranslate"><span class="pre">toxml()</span></code> method now preserves the attribute order specified373by the user.</p>374</div>375<div class="versionchanged">376<p><span class="versionmodified changed">Changed in version 3.9: </span>The <em>standalone</em> parameter was added.</p>377</div>378</dd></dl>379 380<dl class="py method">381<dt class="sig sig-object py" id="xml.dom.minidom.Node.toprettyxml">382<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>383<dd><p>Return a pretty-printed version of the document. <em>indent</em> specifies the384indentation string and defaults to a tabulator; <em>newl</em> specifies the string385emitted at the end of each line and defaults to <code class="docutils literal notranslate"><span class="pre">\n</span></code>.</p>386<p>The <em>encoding</em> argument behaves like the corresponding argument of387<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>388<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>389<div class="versionchanged">390<p><span class="versionmodified changed">Changed in version 3.8: </span>The <code class="xref py py-meth docutils literal notranslate"><span class="pre">toprettyxml()</span></code> method now preserves the attribute order specified391by the user.</p>392</div>393<div class="versionchanged">394<p><span class="versionmodified changed">Changed in version 3.9: </span>The <em>standalone</em> parameter was added.</p>395</div>396</dd></dl>397 398</section>399<section id="dom-example">400<span id="id2"></span><h2>DOM Example<a class="headerlink" href="#dom-example" title="Link to this heading">¶</a></h2>401<p>This example program is a fairly realistic example of a simple program. In this402particular case, we do not take much advantage of the flexibility of the DOM.</p>403<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">xml.dom.minidom</span>404 405<span class="n">document</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;</span><span class="se">\</span>406<span class="s2">&lt;slideshow&gt;</span>407<span class="s2">&lt;title&gt;Demo slideshow&lt;/title&gt;</span>408<span class="s2">&lt;slide&gt;&lt;title&gt;Slide title&lt;/title&gt;</span>409<span class="s2">&lt;point&gt;This is a demo&lt;/point&gt;</span>410<span class="s2">&lt;point&gt;Of a program for processing slides&lt;/point&gt;</span>411<span class="s2">&lt;/slide&gt;</span>412 413<span class="s2">&lt;slide&gt;&lt;title&gt;Another demo slide&lt;/title&gt;</span>414<span class="s2">&lt;point&gt;It is important&lt;/point&gt;</span>415<span class="s2">&lt;point&gt;To have more than&lt;/point&gt;</span>416<span class="s2">&lt;point&gt;one slide&lt;/point&gt;</span>417<span class="s2">&lt;/slide&gt;</span>418<span class="s2">&lt;/slideshow&gt;</span>419<span class="s2">&quot;&quot;&quot;</span>420 421<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>422 423<span class="k">def</span><span class="w"> </span><span class="nf">getText</span><span class="p">(</span><span class="n">nodelist</span><span class="p">):</span>424    <span class="n">rc</span> <span class="o">=</span> <span class="p">[]</span>425    <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">nodelist</span><span class="p">:</span>426        <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>427            <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>428    <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>429 430<span class="k">def</span><span class="w"> </span><span class="nf">handleSlideshow</span><span class="p">(</span><span class="n">slideshow</span><span class="p">):</span>431    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&lt;html&gt;&quot;</span><span class="p">)</span>432    <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>433    <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>434    <span class="n">handleToc</span><span class="p">(</span><span class="n">slides</span><span class="p">)</span>435    <span class="n">handleSlides</span><span class="p">(</span><span class="n">slides</span><span class="p">)</span>436    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&lt;/html&gt;&quot;</span><span class="p">)</span>437 438<span class="k">def</span><span class="w"> </span><span class="nf">handleSlides</span><span class="p">(</span><span class="n">slides</span><span class="p">):</span>439    <span class="k">for</span> <span class="n">slide</span> <span class="ow">in</span> <span class="n">slides</span><span class="p">:</span>440        <span class="n">handleSlide</span><span class="p">(</span><span class="n">slide</span><span class="p">)</span>441 442<span class="k">def</span><span class="w"> </span><span class="nf">handleSlide</span><span class="p">(</span><span class="n">slide</span><span class="p">):</span>443    <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>444    <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>445 446<span class="k">def</span><span class="w"> </span><span class="nf">handleSlideshowTitle</span><span class="p">(</span><span class="n">title</span><span class="p">):</span>447    <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>448 449<span class="k">def</span><span class="w"> </span><span class="nf">handleSlideTitle</span><span class="p">(</span><span class="n">title</span><span class="p">):</span>450    <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>451 452<span class="k">def</span><span class="w"> </span><span class="nf">handlePoints</span><span class="p">(</span><span class="n">points</span><span class="p">):</span>453    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&lt;ul&gt;&quot;</span><span class="p">)</span>454    <span class="k">for</span> <span class="n">point</span> <span class="ow">in</span> <span class="n">points</span><span class="p">:</span>455        <span class="n">handlePoint</span><span class="p">(</span><span class="n">point</span><span class="p">)</span>456    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&lt;/ul&gt;&quot;</span><span class="p">)</span>457 458<span class="k">def</span><span class="w"> </span><span class="nf">handlePoint</span><span class="p">(</span><span class="n">point</span><span class="p">):</span>459    <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>460 461<span class="k">def</span><span class="w"> </span><span class="nf">handleToc</span><span class="p">(</span><span class="n">slides</span><span class="p">):</span>462    <span class="k">for</span> <span class="n">slide</span> <span class="ow">in</span> <span class="n">slides</span><span class="p">:</span>463        <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>464        <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>465 466<span class="n">handleSlideshow</span><span class="p">(</span><span class="n">dom</span><span class="p">)</span>467</pre></div>468</div>469</section>470<section id="minidom-and-the-dom-standard">471<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>472<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code> module is essentially a DOM 1.0-compatible DOM with473some DOM 2 features (primarily namespace features).</p>474<p>Usage of the DOM interface in Python is straight-forward.  The following mapping475rules apply:</p>476<ul class="simple">477<li><p>Interfaces are accessed through instance objects. Applications should not478instantiate the classes themselves; they should use the creator functions479available on the <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> object. Derived interfaces support all480operations (and attributes) from the base interfaces, plus any new operations.</p></li>481<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>482parameters, the arguments are passed in normal order (from left to right).483There 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>484<li><p>IDL attributes map to instance attributes. For compatibility with the OMG IDL485language mapping for Python, an attribute <code class="docutils literal notranslate"><span class="pre">foo</span></code> can also be accessed through486accessor 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>487attributes must not be changed; this is not enforced at runtime.</p></li>488<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>, and489<code class="docutils literal notranslate"><span class="pre">boolean</span></code> all map to Python integer objects.</p></li>490<li><p>The type <code class="docutils literal notranslate"><span class="pre">DOMString</span></code> maps to Python strings. <code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code> supports491either bytes or strings, but will normally produce strings.492Values 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 IDL493<code class="docutils literal notranslate"><span class="pre">null</span></code> value by the DOM specification from the W3C.</p></li>494<li><p><code class="docutils literal notranslate"><span class="pre">const</span></code> declarations map to variables in their respective scope (e.g.495<code class="docutils literal notranslate"><span class="pre">xml.dom.minidom.Node.PROCESSING_INSTRUCTION_NODE</span></code>); they must not be changed.</p></li>496<li><p><code class="docutils literal notranslate"><span class="pre">DOMException</span></code> is currently not supported in <code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code>.497Instead, <code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code> uses standard Python exceptions such as498<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>499<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.500These objects provide the interface defined in the DOM specification, but with501earlier versions of Python they do not support the official API.  They are,502however, much more “Pythonic” than the interface defined in the W3C503recommendations.</p></li>504</ul>505<p>The following interfaces have no implementation in <code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code>:</p>506<ul class="simple">507<li><p><code class="xref py py-class docutils literal notranslate"><span class="pre">DOMTimeStamp</span></code></p></li>508<li><p><code class="xref py py-class docutils literal notranslate"><span class="pre">EntityReference</span></code></p></li>509</ul>510<p>Most of these reflect information in the XML document that is not of general511utility to most DOM users.</p>512<p class="rubric">Footnotes</p>513<aside class="footnote-list brackets">514<aside class="footnote brackets" id="id3" role="doc-footnote">515<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id1">1</a><span class="fn-bracket">]</span></span>516<p>The encoding name included in the XML output should conform to517the appropriate standards. For example, “UTF-8” is valid, but518“UTF8” is not valid in an XML document’s declaration, even though519Python accepts it as an encoding name.520See <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>521and <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>522</aside>523</aside>524</section>525</section>526 527 528            <div class="clearer"></div>529          </div>530        </div>531      </div>532      <div class="sphinxsidebar" role="navigation" aria-label="Main">533        <div class="sphinxsidebarwrapper">534  <div>535    <h3><a href="../contents.html">Table of Contents</a></h3>536    <ul>537<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>538<li><a class="reference internal" href="#dom-objects">DOM Objects</a></li>539<li><a class="reference internal" href="#dom-example">DOM Example</a></li>540<li><a class="reference internal" href="#minidom-and-the-dom-standard">minidom and the DOM standard</a></li>541</ul>542</li>543</ul>544 545  </div>546  <div>547    <h4>Previous topic</h4>548    <p class="topless"><a href="xml.dom.html"549                          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>550  </div>551  <div>552    <h4>Next topic</h4>553    <p class="topless"><a href="xml.dom.pulldom.html"554                          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>555  </div>556  <script>557    document.addEventListener('DOMContentLoaded', () => {558        const title = document.querySelector('meta[property="og:title"]').content;559        const elements = document.querySelectorAll('.improvepage');560        const pageurl = window.location.href.split('?')[0];561        elements.forEach(element => {562            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));563            url.searchParams.set('pagetitle', title);564            url.searchParams.set('pageurl', pageurl);565            url.searchParams.set('pagesource', "library/xml.dom.minidom.rst");566            element.href = url.toString();567        });568    });569  </script>570  <div role="note" aria-label="source link">571    <h3>This page</h3>572    <ul class="this-page-menu">573      <li><a href="../bugs.html">Report a bug</a></li>574      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>575      <li>576        <a href="https://github.com/python/cpython/blob/main/Doc/library/xml.dom.minidom.rst?plain=1"577            rel="nofollow">Show source578        </a>579      </li>580      581    </ul>582  </div>583        </div>584<div id="sidebarbutton" title="Collapse sidebar">585<span>«</span>586</div>587 588      </div>589      <div class="clearer"></div>590    </div>  591    <div class="related" role="navigation" aria-label="Related">592      <h3>Navigation</h3>593      <ul>594        <li class="right" style="margin-right: 10px">595          <a href="../genindex.html" title="General Index"596             >index</a></li>597        <li class="right" >598          <a href="../py-modindex.html" title="Python Module Index"599             >modules</a> |</li>600        <li class="right" >601          <a href="xml.dom.pulldom.html" title="xml.dom.pulldom — Support for building partial DOM trees"602             >next</a> |</li>603        <li class="right" >604          <a href="xml.dom.html" title="xml.dom — The Document Object Model API"605             >previous</a> |</li>606 607          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>608          <li><a href="https://www.python.org/">Python</a> &#187;</li>609          <li class="switchers">610            <div class="language_switcher_placeholder"></div>611            <div class="version_switcher_placeholder"></div>612          </li>613          <li>614              615          </li>616    <li id="cpython-language-and-version">617      <a href="../index.html">3.15.0a6 Documentation</a> &#187;618    </li>619 620          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>621          <li class="nav-item nav-item-2"><a href="markup.html" >Structured Markup Processing Tools</a> &#187;</li>622        <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>623                <li class="right">624                    625 626    <div class="inline-search" role="search">627        <form class="inline-search" action="../search.html" method="get">628          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">629          <input type="submit" value="Go">630        </form>631    </div>632                     |633                </li>634            <li class="right">635<label class="theme-selector-label">636    Theme637    <select class="theme-selector" oninput="activateTheme(this.value)">638        <option value="auto" selected>Auto</option>639        <option value="light">Light</option>640        <option value="dark">Dark</option>641    </select>642</label> |</li>643            644      </ul>645    </div>  646    <div class="footer">647    &copy; <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.648    <br>649    This page is licensed under the Python Software Foundation License Version 2.650    <br>651    Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.652    <br>653    654      See <a href="/license.html">History and License</a> for more information.<br>655    656    657    <br>658 659    The Python Software Foundation is a non-profit corporation.660<a href="https://www.python.org/psf/donations/">Please donate.</a>661<br>662    <br>663      Last updated on Mar 10, 2026 (08:58 UTC).664    665      <a href="/bugs.html">Found a bug</a>?666    667    <br>668 669    Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.670    </div>671 672  </body>673</html>