Linux cpanel.rrshost.in 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64
Apache
: 109.123.238.221 | : 172.69.17.164
128 Domain
8.2.28
aev999
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
HASH IDENTIFIER
README
+ Create Folder
+ Create File
/
usr /
share /
doc /
python2.7 /
html /
library /
[ HOME SHELL ]
Name
Size
Permission
Action
2to3.html
63.71
KB
-rw-r--r--
__builtin__.html
11.79
KB
-rw-r--r--
__future__.html
15.58
KB
-rw-r--r--
__main__.html
8.33
KB
-rw-r--r--
_winreg.html
73.99
KB
-rw-r--r--
abc.html
26.82
KB
-rw-r--r--
aepack.html
15.47
KB
-rw-r--r--
aetools.html
18.79
KB
-rw-r--r--
aetypes.html
27.08
KB
-rw-r--r--
aifc.html
29.59
KB
-rw-r--r--
al.html
22.13
KB
-rw-r--r--
allos.html
35.48
KB
-rw-r--r--
anydbm.html
19.31
KB
-rw-r--r--
archiving.html
10.64
KB
-rw-r--r--
argparse.html
269.59
KB
-rw-r--r--
array.html
35.35
KB
-rw-r--r--
ast.html
42.42
KB
-rw-r--r--
asynchat.html
35.84
KB
-rw-r--r--
asyncore.html
43.22
KB
-rw-r--r--
atexit.html
19.23
KB
-rw-r--r--
audioop.html
41.32
KB
-rw-r--r--
autogil.html
9.77
KB
-rw-r--r--
base64.html
24.8
KB
-rw-r--r--
basehttpserver.html
40.6
KB
-rw-r--r--
bastion.html
13.02
KB
-rw-r--r--
bdb.html
50.06
KB
-rw-r--r--
binascii.html
26.64
KB
-rw-r--r--
binhex.html
12.66
KB
-rw-r--r--
bisect.html
28.52
KB
-rw-r--r--
bsddb.html
32.02
KB
-rw-r--r--
bz2.html
31.92
KB
-rw-r--r--
calendar.html
50.16
KB
-rw-r--r--
carbon.html
54.14
KB
-rw-r--r--
cd.html
35.24
KB
-rw-r--r--
cgi.html
58.4
KB
-rw-r--r--
cgihttpserver.html
15.12
KB
-rw-r--r--
cgitb.html
13.5
KB
-rw-r--r--
chunk.html
17.41
KB
-rw-r--r--
cmath.html
32.41
KB
-rw-r--r--
cmd.html
32.69
KB
-rw-r--r--
code.html
28.92
KB
-rw-r--r--
codecs.html
125.92
KB
-rw-r--r--
codeop.html
16.42
KB
-rw-r--r--
collections.html
150.36
KB
-rw-r--r--
colorpicker.html
9.02
KB
-rw-r--r--
colorsys.html
14.38
KB
-rw-r--r--
commands.html
16.63
KB
-rw-r--r--
compileall.html
21.18
KB
-rw-r--r--
compiler.html
78.14
KB
-rw-r--r--
configparser.html
73.92
KB
-rw-r--r--
constants.html
14.68
KB
-rw-r--r--
contextlib.html
22.91
KB
-rw-r--r--
cookie.html
45.38
KB
-rw-r--r--
cookielib.html
102.78
KB
-rw-r--r--
copy.html
14.21
KB
-rw-r--r--
copy_reg.html
15.82
KB
-rw-r--r--
crypt.html
11.62
KB
-rw-r--r--
crypto.html
8.35
KB
-rw-r--r--
csv.html
82.79
KB
-rw-r--r--
ctypes.html
280.57
KB
-rw-r--r--
curses.ascii.html
28.97
KB
-rw-r--r--
curses.html
200.94
KB
-rw-r--r--
curses.panel.html
18.43
KB
-rw-r--r--
custominterp.html
8.59
KB
-rw-r--r--
datatypes.html
18.84
KB
-rw-r--r--
datetime.html
261.02
KB
-rw-r--r--
dbhash.html
18.4
KB
-rw-r--r--
dbm.html
14.75
KB
-rw-r--r--
debug.html
11.28
KB
-rw-r--r--
decimal.html
239.14
KB
-rw-r--r--
development.html
15.27
KB
-rw-r--r--
difflib.html
96.93
KB
-rw-r--r--
dircache.html
13.66
KB
-rw-r--r--
dis.html
96.52
KB
-rw-r--r--
distribution.html
8.27
KB
-rw-r--r--
distutils.html
10.97
KB
-rw-r--r--
dl.html
19.27
KB
-rw-r--r--
doctest.html
193.18
KB
-rw-r--r--
docxmlrpcserver.html
20.02
KB
-rw-r--r--
dumbdbm.html
16.74
KB
-rw-r--r--
dummy_thread.html
11.04
KB
-rw-r--r--
dummy_threading.html
9.96
KB
-rw-r--r--
easydialogs.html
38.83
KB
-rw-r--r--
email-examples.html
47.2
KB
-rw-r--r--
email.charset.html
32.45
KB
-rw-r--r--
email.encoders.html
14.09
KB
-rw-r--r--
email.errors.html
19.2
KB
-rw-r--r--
email.generator.html
24.78
KB
-rw-r--r--
email.header.html
31.12
KB
-rw-r--r--
email.html
55.3
KB
-rw-r--r--
email.iterators.html
14.22
KB
-rw-r--r--
email.message.html
74.91
KB
-rw-r--r--
email.mime.html
34.51
KB
-rw-r--r--
email.parser.html
37.09
KB
-rw-r--r--
email.utils.html
30.04
KB
-rw-r--r--
ensurepip.html
20.21
KB
-rw-r--r--
errno.html
52.31
KB
-rw-r--r--
exceptions.html
73.4
KB
-rw-r--r--
fcntl.html
27.85
KB
-rw-r--r--
filecmp.html
26.49
KB
-rw-r--r--
fileformats.html
10.21
KB
-rw-r--r--
fileinput.html
29.36
KB
-rw-r--r--
filesys.html
11.55
KB
-rw-r--r--
fl.html
71.58
KB
-rw-r--r--
fm.html
15
KB
-rw-r--r--
fnmatch.html
17.78
KB
-rw-r--r--
formatter.html
43.91
KB
-rw-r--r--
fpectl.html
17.84
KB
-rw-r--r--
fpformat.html
12.65
KB
-rw-r--r--
fractions.html
27.17
KB
-rw-r--r--
framework.html
44.24
KB
-rw-r--r--
frameworks.html
8.11
KB
-rw-r--r--
ftplib.html
56.56
KB
-rw-r--r--
functions.html
216.84
KB
-rw-r--r--
functools.html
31.06
KB
-rw-r--r--
future_builtins.html
15.9
KB
-rw-r--r--
gc.html
30.74
KB
-rw-r--r--
gdbm.html
19.35
KB
-rw-r--r--
gensuitemodule.html
14.54
KB
-rw-r--r--
getopt.html
26.56
KB
-rw-r--r--
getpass.html
12.5
KB
-rw-r--r--
gettext.html
91.32
KB
-rw-r--r--
gl.html
26.71
KB
-rw-r--r--
glob.html
15.42
KB
-rw-r--r--
grp.html
12.33
KB
-rw-r--r--
gzip.html
21.95
KB
-rw-r--r--
hashlib.html
27.4
KB
-rw-r--r--
heapq.html
36.72
KB
-rw-r--r--
hmac.html
15.97
KB
-rw-r--r--
hotshot.html
22.69
KB
-rw-r--r--
htmllib.html
29.9
KB
-rw-r--r--
htmlparser.html
45.11
KB
-rw-r--r--
httplib.html
78.55
KB
-rw-r--r--
i18n.html
10.61
KB
-rw-r--r--
ic.html
22.03
KB
-rw-r--r--
idle.html
45.74
KB
-rw-r--r--
imageop.html
20.94
KB
-rw-r--r--
imaplib.html
69.9
KB
-rw-r--r--
imgfile.html
14.91
KB
-rw-r--r--
imghdr.html
13.43
KB
-rw-r--r--
imp.html
41.48
KB
-rw-r--r--
importlib.html
10.27
KB
-rw-r--r--
imputil.html
36.11
KB
-rw-r--r--
index.html
82.54
KB
-rw-r--r--
inspect.html
64.31
KB
-rw-r--r--
internet.html
26.77
KB
-rw-r--r--
intro.html
9.76
KB
-rw-r--r--
io.html
122.3
KB
-rw-r--r--
ipc.html
17.18
KB
-rw-r--r--
itertools.html
129.91
KB
-rw-r--r--
jpeg.html
15.36
KB
-rw-r--r--
json.html
79.09
KB
-rw-r--r--
keyword.html
9.27
KB
-rw-r--r--
language.html
12.35
KB
-rw-r--r--
linecache.html
12.7
KB
-rw-r--r--
locale.html
68.54
KB
-rw-r--r--
logging.config.html
82.23
KB
-rw-r--r--
logging.handlers.html
91.96
KB
-rw-r--r--
logging.html
123.15
KB
-rw-r--r--
mac.html
24.49
KB
-rw-r--r--
macos.html
18.51
KB
-rw-r--r--
macosa.html
14.55
KB
-rw-r--r--
macostools.html
19.67
KB
-rw-r--r--
macpath.html
9.19
KB
-rw-r--r--
mailbox.html
185.53
KB
-rw-r--r--
mailcap.html
15.3
KB
-rw-r--r--
markup.html
20.37
KB
-rw-r--r--
marshal.html
19.88
KB
-rw-r--r--
math.html
50.52
KB
-rw-r--r--
md5.html
16.65
KB
-rw-r--r--
mhlib.html
30.04
KB
-rw-r--r--
mimetools.html
23.84
KB
-rw-r--r--
mimetypes.html
35.82
KB
-rw-r--r--
mimewriter.html
18.19
KB
-rw-r--r--
mimify.html
16.96
KB
-rw-r--r--
miniaeframe.html
14.5
KB
-rw-r--r--
misc.html
7.77
KB
-rw-r--r--
mm.html
10.19
KB
-rw-r--r--
mmap.html
33.52
KB
-rw-r--r--
modulefinder.html
19.85
KB
-rw-r--r--
modules.html
9.68
KB
-rw-r--r--
msilib.html
72.78
KB
-rw-r--r--
msvcrt.html
24.1
KB
-rw-r--r--
multifile.html
28.82
KB
-rw-r--r--
multiprocessing.html
423.97
KB
-rw-r--r--
mutex.html
13.56
KB
-rw-r--r--
netdata.html
19.28
KB
-rw-r--r--
netrc.html
15.51
KB
-rw-r--r--
new.html
16.1
KB
-rw-r--r--
nis.html
13.19
KB
-rw-r--r--
nntplib.html
51.08
KB
-rw-r--r--
numbers.html
40.91
KB
-rw-r--r--
numeric.html
14.85
KB
-rw-r--r--
operator.html
118.32
KB
-rw-r--r--
optparse.html
251.08
KB
-rw-r--r--
os.html
270.49
KB
-rw-r--r--
os.path.html
48.87
KB
-rw-r--r--
ossaudiodev.html
49.79
KB
-rw-r--r--
othergui.html
9.98
KB
-rw-r--r--
parser.html
44.52
KB
-rw-r--r--
pdb.html
41.44
KB
-rw-r--r--
persistence.html
16.25
KB
-rw-r--r--
pickle.html
107.94
KB
-rw-r--r--
pickletools.html
13.21
KB
-rw-r--r--
pipes.html
21.85
KB
-rw-r--r--
pkgutil.html
30.59
KB
-rw-r--r--
platform.html
40.14
KB
-rw-r--r--
plistlib.html
20.96
KB
-rw-r--r--
popen2.html
30.13
KB
-rw-r--r--
poplib.html
27.93
KB
-rw-r--r--
posix.html
17.27
KB
-rw-r--r--
posixfile.html
23.68
KB
-rw-r--r--
pprint.html
36.42
KB
-rw-r--r--
profile.html
76.65
KB
-rw-r--r--
pty.html
11.42
KB
-rw-r--r--
pwd.html
13.53
KB
-rw-r--r--
py_compile.html
13.33
KB
-rw-r--r--
pyclbr.html
18.14
KB
-rw-r--r--
pydoc.html
14.33
KB
-rw-r--r--
pyexpat.html
93.28
KB
-rw-r--r--
python.html
13.53
KB
-rw-r--r--
queue.html
29.64
KB
-rw-r--r--
quopri.html
14.5
KB
-rw-r--r--
random.html
47.78
KB
-rw-r--r--
re.html
163.11
KB
-rw-r--r--
readline.html
41.2
KB
-rw-r--r--
repr.html
24.57
KB
-rw-r--r--
resource.html
30.86
KB
-rw-r--r--
restricted.html
12.69
KB
-rw-r--r--
rexec.html
43.59
KB
-rw-r--r--
rfc822.html
51.25
KB
-rw-r--r--
rlcompleter.html
15.29
KB
-rw-r--r--
robotparser.html
15.01
KB
-rw-r--r--
runpy.html
23.55
KB
-rw-r--r--
sched.html
21.76
KB
-rw-r--r--
scrolledtext.html
10.67
KB
-rw-r--r--
select.html
50.17
KB
-rw-r--r--
sets.html
39.92
KB
-rw-r--r--
sgi.html
11.09
KB
-rw-r--r--
sgmllib.html
38.77
KB
-rw-r--r--
sha.html
14.55
KB
-rw-r--r--
shelve.html
32.93
KB
-rw-r--r--
shlex.html
38.43
KB
-rw-r--r--
shutil.html
49.49
KB
-rw-r--r--
signal.html
36.52
KB
-rw-r--r--
simplehttpserver.html
21.57
KB
-rw-r--r--
simplexmlrpcserver.html
40.41
KB
-rw-r--r--
site.html
29
KB
-rw-r--r--
smtpd.html
15.64
KB
-rw-r--r--
smtplib.html
51.86
KB
-rw-r--r--
sndhdr.html
12.05
KB
-rw-r--r--
socket.html
126.94
KB
-rw-r--r--
socketserver.html
81.38
KB
-rw-r--r--
someos.html
17.09
KB
-rw-r--r--
spwd.html
12.25
KB
-rw-r--r--
sqlite3.html
154.12
KB
-rw-r--r--
ssl.html
214.5
KB
-rw-r--r--
stat.html
41.11
KB
-rw-r--r--
statvfs.html
13.24
KB
-rw-r--r--
stdtypes.html
309.83
KB
-rw-r--r--
string.html
129.58
KB
-rw-r--r--
stringio.html
21.1
KB
-rw-r--r--
stringprep.html
21.4
KB
-rw-r--r--
strings.html
16.42
KB
-rw-r--r--
struct.html
47.68
KB
-rw-r--r--
subprocess.html
117
KB
-rw-r--r--
sun.html
7.83
KB
-rw-r--r--
sunau.html
35.43
KB
-rw-r--r--
sunaudio.html
21.05
KB
-rw-r--r--
symbol.html
9.06
KB
-rw-r--r--
symtable.html
29.03
KB
-rw-r--r--
sys.html
118.12
KB
-rw-r--r--
sysconfig.html
28.8
KB
-rw-r--r--
syslog.html
21.29
KB
-rw-r--r--
tabnanny.html
12.78
KB
-rw-r--r--
tarfile.html
99.54
KB
-rw-r--r--
telnetlib.html
30.46
KB
-rw-r--r--
tempfile.html
35.02
KB
-rw-r--r--
termios.html
19.22
KB
-rw-r--r--
test.html
61.42
KB
-rw-r--r--
textwrap.html
32.28
KB
-rw-r--r--
thread.html
22.67
KB
-rw-r--r--
threading.html
92.04
KB
-rw-r--r--
time.html
65.55
KB
-rw-r--r--
timeit.html
44.38
KB
-rw-r--r--
tix.html
56.73
KB
-rw-r--r--
tk.html
26.76
KB
-rw-r--r--
tkinter.html
86.67
KB
-rw-r--r--
token.html
27.31
KB
-rw-r--r--
tokenize.html
21.69
KB
-rw-r--r--
trace.html
33.91
KB
-rw-r--r--
traceback.html
44.22
KB
-rw-r--r--
ttk.html
123.83
KB
-rw-r--r--
tty.html
10.95
KB
-rw-r--r--
turtle.html
246.17
KB
-rw-r--r--
types.html
33.66
KB
-rw-r--r--
undoc.html
25.54
KB
-rw-r--r--
unicodedata.html
22.64
KB
-rw-r--r--
unittest.html
246.75
KB
-rw-r--r--
unix.html
11.9
KB
-rw-r--r--
urllib.html
71.61
KB
-rw-r--r--
urllib2.html
128.77
KB
-rw-r--r--
urlparse.html
49.04
KB
-rw-r--r--
user.html
13.41
KB
-rw-r--r--
userdict.html
32.96
KB
-rw-r--r--
uu.html
13.25
KB
-rw-r--r--
uuid.html
33.55
KB
-rw-r--r--
warnings.html
51.86
KB
-rw-r--r--
wave.html
29.08
KB
-rw-r--r--
weakref.html
41.14
KB
-rw-r--r--
webbrowser.html
29.53
KB
-rw-r--r--
whichdb.html
10.44
KB
-rw-r--r--
windows.html
10.37
KB
-rw-r--r--
winsound.html
22.56
KB
-rw-r--r--
wsgiref.html
94.38
KB
-rw-r--r--
xdrlib.html
38.05
KB
-rw-r--r--
xml.dom.html
110.39
KB
-rw-r--r--
xml.dom.minidom.html
45.23
KB
-rw-r--r--
xml.dom.pulldom.html
16.32
KB
-rw-r--r--
xml.etree.elementtree.html
124.2
KB
-rw-r--r--
xml.html
18.76
KB
-rw-r--r--
xml.sax.handler.html
47.5
KB
-rw-r--r--
xml.sax.html
26.04
KB
-rw-r--r--
xml.sax.reader.html
51.4
KB
-rw-r--r--
xml.sax.utils.html
18.11
KB
-rw-r--r--
xmlrpclib.html
71.79
KB
-rw-r--r--
zipfile.html
67.26
KB
-rw-r--r--
zipimport.html
24.32
KB
-rw-r--r--
zlib.html
34.41
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : xml.dom.html
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> <title>19.8. xml.dom — The Document Object Model API — Python 2.7.18 documentation</title> <link rel="stylesheet" type="text/css" href="../_static/pygments.css" /> <link rel="stylesheet" type="text/css" href="../_static/classic.css" /> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> <script src="../_static/doctools.js"></script> <script src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.18 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="next" title="19.9. xml.dom.minidom — Minimal DOM implementation" href="xml.dom.minidom.html" /> <link rel="prev" title="19.7. xml.etree.ElementTree — The ElementTree XML API" href="xml.etree.elementtree.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <link rel="canonical" href="file:///usr/share/doc/python2.7/html/library/xml.dom.html" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head><body> <div id="outdated-warning" style="padding: .5em; text-align: center; background-color: #FFBABA; color: #6A0E0E;"> This document is for an old version of Python that is <a href="https://devguide.python.org/devcycle/#end-of-life-branches">no longer supported</a>. You should install the python3 and python3-doc packages and read the <a href="file:///usr/share/doc/python3-doc/html/library/xml.dom.html"> Python documentation for the Python3 version packaged in this release</a>. </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="xml.dom.minidom.html" title="19.9. xml.dom.minidom — Minimal DOM implementation" accesskey="N">next</a> |</li> <li class="right" > <a href="xml.etree.elementtree.html" title="19.7. xml.etree.ElementTree — The ElementTree XML API" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.18 documentation</a> » </li> <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li> <li class="nav-item nav-item-2"><a href="markup.html" accesskey="U"><span class="section-number">19. </span>Structured Markup Processing Tools</a> »</li> <li class="nav-item nav-item-this"><a href=""><span class="section-number">19.8. </span><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom</span></code> — The Document Object Model API</a></li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <section id="module-xml.dom"> <span id="xml-dom-the-document-object-model-api"></span><h1><span class="section-number">19.8. </span><a class="reference internal" href="#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> — The Document Object Model API<a class="headerlink" href="#module-xml.dom" title="Permalink to this headline">¶</a></h1> <div class="versionadded"> <p><span class="versionmodified added">New in version 2.0.</span></p> </div> <p>The Document Object Model, or “DOM,” is a cross-language API from the World Wide Web Consortium (W3C) for accessing and modifying XML documents. A DOM implementation presents an XML document as a tree structure, or allows client code to build such a structure from scratch. It then gives access to the structure through a set of objects which provided well-known interfaces.</p> <p>The DOM is extremely useful for random-access applications. SAX only allows you a view of one bit of the document at a time. If you are looking at one SAX element, you have no access to another. If you are looking at a text node, you have no access to a containing element. When you write a SAX application, you need to keep track of your program’s position in the document somewhere in your own code. SAX does not do it for you. Also, if you need to look ahead in the XML document, you are just out of luck.</p> <p>Some applications are simply impossible in an event driven model with no access to a tree. Of course you could build some sort of tree yourself in SAX events, but the DOM allows you to avoid writing that code. The DOM is a standard tree representation for XML data.</p> <p>The Document Object Model is being defined by the W3C in stages, or “levels” in their terminology. The Python mapping of the API is substantially based on the DOM Level 2 recommendation.</p> <p>DOM applications typically start by parsing some XML into a DOM. How this is accomplished is not covered at all by DOM Level 1, and Level 2 provides only limited improvements: There is a <code class="xref py py-class docutils literal notranslate"><span class="pre">DOMImplementation</span></code> object class which provides access to <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> creation methods, but no way to access an XML reader/parser/Document builder in an implementation-independent way. There is also no well-defined way to access these methods without an existing <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> object. In Python, each DOM implementation will provide a function <a class="reference internal" href="#xml.dom.getDOMImplementation" title="xml.dom.getDOMImplementation"><code class="xref py py-func docutils literal notranslate"><span class="pre">getDOMImplementation()</span></code></a>. DOM Level 3 adds a Load/Store specification, which defines an interface to the reader, but this is not yet available in the Python standard library.</p> <p>Once you have a DOM document object, you can access the parts of your XML document through its properties and methods. These properties are defined in the DOM specification; this portion of the reference manual describes the interpretation of the specification in Python.</p> <p>The specification provided by the W3C defines the DOM API for Java, ECMAScript, and OMG IDL. The Python mapping defined here is based in large part on the IDL version of the specification, but strict compliance is not required (though implementations are free to support the strict mapping from IDL). See section <a class="reference internal" href="#dom-conformance"><span class="std std-ref">Conformance</span></a> for a detailed discussion of mapping requirements.</p> <div class="admonition seealso"> <p class="admonition-title">See also</p> <dl class="simple"> <dt><a class="reference external" href="https://www.w3.org/TR/DOM-Level-2-Core/">Document Object Model (DOM) Level 2 Specification</a></dt><dd><p>The W3C recommendation upon which the Python DOM API is based.</p> </dd> <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="xml.dom.minidom.html#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> </dd> <dt><a class="reference external" href="http://www.omg.org/spec/PYTH/1.2/PDF">Python Language Mapping Specification</a></dt><dd><p>This specifies the mapping from OMG IDL to Python.</p> </dd> </dl> </div> <section id="module-contents"> <h2><span class="section-number">19.8.1. </span>Module Contents<a class="headerlink" href="#module-contents" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference internal" href="#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> contains the following functions:</p> <dl class="py function"> <dt class="sig sig-object py" id="xml.dom.registerDOMImplementation"> <span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">registerDOMImplementation</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">factory</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.registerDOMImplementation" title="Permalink to this definition">¶</a></dt> <dd><p>Register the <em>factory</em> function with the name <em>name</em>. The factory function should return an object which implements the <code class="xref py py-class docutils literal notranslate"><span class="pre">DOMImplementation</span></code> interface. The factory function can return the same object every time, or a new one for each call, as appropriate for the specific implementation (e.g. if that implementation supports some customization).</p> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="xml.dom.getDOMImplementation"> <span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">getDOMImplementation</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">features</span></span></em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.getDOMImplementation" title="Permalink to this definition">¶</a></dt> <dd><p>Return a suitable DOM implementation. The <em>name</em> is either well-known, the module name of a DOM implementation, or <code class="docutils literal notranslate"><span class="pre">None</span></code>. If it is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, imports the corresponding module and returns a <code class="xref py py-class docutils literal notranslate"><span class="pre">DOMImplementation</span></code> object if the import succeeds. If no name is given, and if the environment variable <span class="target" id="index-0"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHON_DOM</span></code> is set, this variable is used to find the implementation.</p> <p>If name is not given, this examines the available implementations to find one with the required feature set. If no implementation can be found, raise an <code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportError</span></code>. The features list must be a sequence of <code class="docutils literal notranslate"><span class="pre">(feature,</span> <span class="pre">version)</span></code> pairs which are passed to the <code class="xref py py-meth docutils literal notranslate"><span class="pre">hasFeature()</span></code> method on available <code class="xref py py-class docutils literal notranslate"><span class="pre">DOMImplementation</span></code> objects.</p> </dd></dl> <p>Some convenience constants are also provided:</p> <dl class="py data"> <dt class="sig sig-object py" id="xml.dom.EMPTY_NAMESPACE"> <span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">EMPTY_NAMESPACE</span></span><a class="headerlink" href="#xml.dom.EMPTY_NAMESPACE" title="Permalink to this definition">¶</a></dt> <dd><p>The value used to indicate that no namespace is associated with a node in the DOM. This is typically found as the <code class="xref py py-attr docutils literal notranslate"><span class="pre">namespaceURI</span></code> of a node, or used as the <em>namespaceURI</em> parameter to a namespaces-specific method.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 2.2.</span></p> </div> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.dom.XML_NAMESPACE"> <span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">XML_NAMESPACE</span></span><a class="headerlink" href="#xml.dom.XML_NAMESPACE" title="Permalink to this definition">¶</a></dt> <dd><p>The namespace URI associated with the reserved prefix <code class="docutils literal notranslate"><span class="pre">xml</span></code>, as defined by <a class="reference external" href="https://www.w3.org/TR/REC-xml-names/">Namespaces in XML</a> (section 4).</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 2.2.</span></p> </div> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.dom.XMLNS_NAMESPACE"> <span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">XMLNS_NAMESPACE</span></span><a class="headerlink" href="#xml.dom.XMLNS_NAMESPACE" title="Permalink to this definition">¶</a></dt> <dd><p>The namespace URI for namespace declarations, as defined by <a class="reference external" href="https://www.w3.org/TR/DOM-Level-2-Core/core.html">Document Object Model (DOM) Level 2 Core Specification</a> (section 1.1.8).</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 2.2.</span></p> </div> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.dom.XHTML_NAMESPACE"> <span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">XHTML_NAMESPACE</span></span><a class="headerlink" href="#xml.dom.XHTML_NAMESPACE" title="Permalink to this definition">¶</a></dt> <dd><p>The URI of the XHTML namespace as defined by <a class="reference external" href="https://www.w3.org/TR/xhtml1/">XHTML 1.0: The Extensible HyperText Markup Language</a> (section 3.1.1).</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 2.2.</span></p> </div> </dd></dl> <p>In addition, <a class="reference internal" href="#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> contains a base <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code> class and the DOM exception classes. The <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code> class provided by this module does not implement any of the methods or attributes defined by the DOM specification; concrete DOM implementations must provide those. The <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code> class provided as part of this module does provide the constants used for the <code class="xref py py-attr docutils literal notranslate"><span class="pre">nodeType</span></code> attribute on concrete <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code> objects; they are located within the class rather than at the module level to conform with the DOM specifications.</p> </section> <section id="objects-in-the-dom"> <span id="dom-objects"></span><h2><span class="section-number">19.8.2. </span>Objects in the DOM<a class="headerlink" href="#objects-in-the-dom" title="Permalink to this headline">¶</a></h2> <p>The definitive documentation for the DOM is the DOM specification from the W3C.</p> <p>Note that DOM attributes may also be manipulated as nodes instead of as simple strings. It is fairly rare that you must do this, however, so this usage is not yet documented.</p> <table class="docutils align-default"> <colgroup> <col style="width: 32%" /> <col style="width: 35%" /> <col style="width: 33%" /> </colgroup> <thead> <tr class="row-odd"><th class="head"><p>Interface</p></th> <th class="head"><p>Section</p></th> <th class="head"><p>Purpose</p></th> </tr> </thead> <tbody> <tr class="row-even"><td><p><code class="xref py py-class docutils literal notranslate"><span class="pre">DOMImplementation</span></code></p></td> <td><p><a class="reference internal" href="#dom-implementation-objects"><span class="std std-ref">DOMImplementation Objects</span></a></p></td> <td><p>Interface to the underlying implementation.</p></td> </tr> <tr class="row-odd"><td><p><code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code></p></td> <td><p><a class="reference internal" href="#dom-node-objects"><span class="std std-ref">Node Objects</span></a></p></td> <td><p>Base interface for most objects in a document.</p></td> </tr> <tr class="row-even"><td><p><code class="xref py py-class docutils literal notranslate"><span class="pre">NodeList</span></code></p></td> <td><p><a class="reference internal" href="#dom-nodelist-objects"><span class="std std-ref">NodeList Objects</span></a></p></td> <td><p>Interface for a sequence of nodes.</p></td> </tr> <tr class="row-odd"><td><p><code class="xref py py-class docutils literal notranslate"><span class="pre">DocumentType</span></code></p></td> <td><p><a class="reference internal" href="#dom-documenttype-objects"><span class="std std-ref">DocumentType Objects</span></a></p></td> <td><p>Information about the declarations needed to process a document.</p></td> </tr> <tr class="row-even"><td><p><code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code></p></td> <td><p><a class="reference internal" href="#dom-document-objects"><span class="std std-ref">Document Objects</span></a></p></td> <td><p>Object which represents an entire document.</p></td> </tr> <tr class="row-odd"><td><p><code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code></p></td> <td><p><a class="reference internal" href="#dom-element-objects"><span class="std std-ref">Element Objects</span></a></p></td> <td><p>Element nodes in the document hierarchy.</p></td> </tr> <tr class="row-even"><td><p><code class="xref py py-class docutils literal notranslate"><span class="pre">Attr</span></code></p></td> <td><p><a class="reference internal" href="#dom-attr-objects"><span class="std std-ref">Attr Objects</span></a></p></td> <td><p>Attribute value nodes on element nodes.</p></td> </tr> <tr class="row-odd"><td><p><code class="xref py py-class docutils literal notranslate"><span class="pre">Comment</span></code></p></td> <td><p><a class="reference internal" href="#dom-comment-objects"><span class="std std-ref">Comment Objects</span></a></p></td> <td><p>Representation of comments in the source document.</p></td> </tr> <tr class="row-even"><td><p><code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code></p></td> <td><p><a class="reference internal" href="#dom-text-objects"><span class="std std-ref">Text and CDATASection Objects</span></a></p></td> <td><p>Nodes containing textual content from the document.</p></td> </tr> <tr class="row-odd"><td><p><code class="xref py py-class docutils literal notranslate"><span class="pre">ProcessingInstruction</span></code></p></td> <td><p><a class="reference internal" href="#dom-pi-objects"><span class="std std-ref">ProcessingInstruction Objects</span></a></p></td> <td><p>Processing instruction representation.</p></td> </tr> </tbody> </table> <p>An additional section describes the exceptions defined for working with the DOM in Python.</p> <section id="domimplementation-objects"> <span id="dom-implementation-objects"></span><h3><span class="section-number">19.8.2.1. </span>DOMImplementation Objects<a class="headerlink" href="#domimplementation-objects" title="Permalink to this headline">¶</a></h3> <p>The <code class="xref py py-class docutils literal notranslate"><span class="pre">DOMImplementation</span></code> interface provides a way for applications to determine the availability of particular features in the DOM they are using. DOM Level 2 added the ability to create new <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> and <code class="xref py py-class docutils literal notranslate"><span class="pre">DocumentType</span></code> objects using the <code class="xref py py-class docutils literal notranslate"><span class="pre">DOMImplementation</span></code> as well.</p> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.DOMImplementation.hasFeature"> <span class="sig-prename descclassname"><span class="pre">DOMImplementation.</span></span><span class="sig-name descname"><span class="pre">hasFeature</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">feature</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">version</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.DOMImplementation.hasFeature" title="Permalink to this definition">¶</a></dt> <dd><p>Return true if the feature identified by the pair of strings <em>feature</em> and <em>version</em> is implemented.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.DOMImplementation.createDocument"> <span class="sig-prename descclassname"><span class="pre">DOMImplementation.</span></span><span class="sig-name descname"><span class="pre">createDocument</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">namespaceUri</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qualifiedName</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">doctype</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.DOMImplementation.createDocument" title="Permalink to this definition">¶</a></dt> <dd><p>Return a new <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> object (the root of the DOM), with a child <code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code> object having the given <em>namespaceUri</em> and <em>qualifiedName</em>. The <em>doctype</em> must be a <code class="xref py py-class docutils literal notranslate"><span class="pre">DocumentType</span></code> object created by <a class="reference internal" href="#xml.dom.DOMImplementation.createDocumentType" title="xml.dom.DOMImplementation.createDocumentType"><code class="xref py py-meth docutils literal notranslate"><span class="pre">createDocumentType()</span></code></a>, or <code class="docutils literal notranslate"><span class="pre">None</span></code>. In the Python DOM API, the first two arguments can also be <code class="docutils literal notranslate"><span class="pre">None</span></code> in order to indicate that no <code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code> child is to be created.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.DOMImplementation.createDocumentType"> <span class="sig-prename descclassname"><span class="pre">DOMImplementation.</span></span><span class="sig-name descname"><span class="pre">createDocumentType</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">qualifiedName</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">publicId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">systemId</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.DOMImplementation.createDocumentType" title="Permalink to this definition">¶</a></dt> <dd><p>Return a new <code class="xref py py-class docutils literal notranslate"><span class="pre">DocumentType</span></code> object that encapsulates the given <em>qualifiedName</em>, <em>publicId</em>, and <em>systemId</em> strings, representing the information contained in an XML document type declaration.</p> </dd></dl> </section> <section id="node-objects"> <span id="dom-node-objects"></span><h3><span class="section-number">19.8.2.2. </span>Node Objects<a class="headerlink" href="#node-objects" title="Permalink to this headline">¶</a></h3> <p>All of the components of an XML document are subclasses of <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code>.</p> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Node.nodeType"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">nodeType</span></span><a class="headerlink" href="#xml.dom.Node.nodeType" title="Permalink to this definition">¶</a></dt> <dd><p>An integer representing the node type. Symbolic constants for the types are on the <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code> object: <code class="xref py py-const docutils literal notranslate"><span class="pre">ELEMENT_NODE</span></code>, <code class="xref py py-const docutils literal notranslate"><span class="pre">ATTRIBUTE_NODE</span></code>, <code class="xref py py-const docutils literal notranslate"><span class="pre">TEXT_NODE</span></code>, <code class="xref py py-const docutils literal notranslate"><span class="pre">CDATA_SECTION_NODE</span></code>, <code class="xref py py-const docutils literal notranslate"><span class="pre">ENTITY_NODE</span></code>, <code class="xref py py-const docutils literal notranslate"><span class="pre">PROCESSING_INSTRUCTION_NODE</span></code>, <code class="xref py py-const docutils literal notranslate"><span class="pre">COMMENT_NODE</span></code>, <code class="xref py py-const docutils literal notranslate"><span class="pre">DOCUMENT_NODE</span></code>, <code class="xref py py-const docutils literal notranslate"><span class="pre">DOCUMENT_TYPE_NODE</span></code>, <code class="xref py py-const docutils literal notranslate"><span class="pre">NOTATION_NODE</span></code>. This is a read-only attribute.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Node.parentNode"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">parentNode</span></span><a class="headerlink" href="#xml.dom.Node.parentNode" title="Permalink to this definition">¶</a></dt> <dd><p>The parent of the current node, or <code class="docutils literal notranslate"><span class="pre">None</span></code> for the document node. The value is always a <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code> object or <code class="docutils literal notranslate"><span class="pre">None</span></code>. For <code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code> nodes, this will be the parent element, except for the root element, in which case it will be the <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> object. For <code class="xref py py-class docutils literal notranslate"><span class="pre">Attr</span></code> nodes, this is always <code class="docutils literal notranslate"><span class="pre">None</span></code>. This is a read-only attribute.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Node.attributes"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">attributes</span></span><a class="headerlink" href="#xml.dom.Node.attributes" title="Permalink to this definition">¶</a></dt> <dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">NamedNodeMap</span></code> of attribute objects. Only elements have actual values for this; others provide <code class="docutils literal notranslate"><span class="pre">None</span></code> for this attribute. This is a read-only attribute.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Node.previousSibling"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">previousSibling</span></span><a class="headerlink" href="#xml.dom.Node.previousSibling" title="Permalink to this definition">¶</a></dt> <dd><p>The node that immediately precedes this one with the same parent. For instance the element with an end-tag that comes just before the <em>self</em> element’s start-tag. Of course, XML documents are made up of more than just elements so the previous sibling could be text, a comment, or something else. If this node is the first child of the parent, this attribute will be <code class="docutils literal notranslate"><span class="pre">None</span></code>. This is a read-only attribute.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Node.nextSibling"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">nextSibling</span></span><a class="headerlink" href="#xml.dom.Node.nextSibling" title="Permalink to this definition">¶</a></dt> <dd><p>The node that immediately follows this one with the same parent. See also <a class="reference internal" href="#xml.dom.Node.previousSibling" title="xml.dom.Node.previousSibling"><code class="xref py py-attr docutils literal notranslate"><span class="pre">previousSibling</span></code></a>. If this is the last child of the parent, this attribute will be <code class="docutils literal notranslate"><span class="pre">None</span></code>. This is a read-only attribute.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Node.childNodes"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">childNodes</span></span><a class="headerlink" href="#xml.dom.Node.childNodes" title="Permalink to this definition">¶</a></dt> <dd><p>A list of nodes contained within this node. This is a read-only attribute.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Node.firstChild"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">firstChild</span></span><a class="headerlink" href="#xml.dom.Node.firstChild" title="Permalink to this definition">¶</a></dt> <dd><p>The first child of the node, if there are any, or <code class="docutils literal notranslate"><span class="pre">None</span></code>. This is a read-only attribute.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Node.lastChild"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">lastChild</span></span><a class="headerlink" href="#xml.dom.Node.lastChild" title="Permalink to this definition">¶</a></dt> <dd><p>The last child of the node, if there are any, or <code class="docutils literal notranslate"><span class="pre">None</span></code>. This is a read-only attribute.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Node.localName"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">localName</span></span><a class="headerlink" href="#xml.dom.Node.localName" title="Permalink to this definition">¶</a></dt> <dd><p>The part of the <code class="xref py py-attr docutils literal notranslate"><span class="pre">tagName</span></code> following the colon if there is one, else the entire <code class="xref py py-attr docutils literal notranslate"><span class="pre">tagName</span></code>. The value is a string.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Node.prefix"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">prefix</span></span><a class="headerlink" href="#xml.dom.Node.prefix" title="Permalink to this definition">¶</a></dt> <dd><p>The part of the <code class="xref py py-attr docutils literal notranslate"><span class="pre">tagName</span></code> preceding the colon if there is one, else the empty string. The value is a string, or <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Node.namespaceURI"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">namespaceURI</span></span><a class="headerlink" href="#xml.dom.Node.namespaceURI" title="Permalink to this definition">¶</a></dt> <dd><p>The namespace associated with the element name. This will be a string or <code class="docutils literal notranslate"><span class="pre">None</span></code>. This is a read-only attribute.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Node.nodeName"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">nodeName</span></span><a class="headerlink" href="#xml.dom.Node.nodeName" title="Permalink to this definition">¶</a></dt> <dd><p>This has a different meaning for each node type; see the DOM specification for details. You can always get the information you would get here from another property such as the <code class="xref py py-attr docutils literal notranslate"><span class="pre">tagName</span></code> property for elements or the <code class="xref py py-attr docutils literal notranslate"><span class="pre">name</span></code> property for attributes. For all node types, the value of this attribute will be either a string or <code class="docutils literal notranslate"><span class="pre">None</span></code>. This is a read-only attribute.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Node.nodeValue"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">nodeValue</span></span><a class="headerlink" href="#xml.dom.Node.nodeValue" title="Permalink to this definition">¶</a></dt> <dd><p>This has a different meaning for each node type; see the DOM specification for details. The situation is similar to that with <a class="reference internal" href="#xml.dom.Node.nodeName" title="xml.dom.Node.nodeName"><code class="xref py py-attr docutils literal notranslate"><span class="pre">nodeName</span></code></a>. The value is a string or <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Node.hasAttributes"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">hasAttributes</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Node.hasAttributes" title="Permalink to this definition">¶</a></dt> <dd><p>Returns true if the node has any attributes.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Node.hasChildNodes"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">hasChildNodes</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Node.hasChildNodes" title="Permalink to this definition">¶</a></dt> <dd><p>Returns true if the node has any child nodes.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Node.isSameNode"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">isSameNode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Node.isSameNode" title="Permalink to this definition">¶</a></dt> <dd><p>Returns true if <em>other</em> refers to the same node as this node. This is especially useful for DOM implementations which use any sort of proxy architecture (because more than one object can refer to the same node).</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>This is based on a proposed DOM Level 3 API which is still in the “working draft” stage, but this particular interface appears uncontroversial. Changes from the W3C will not necessarily affect this method in the Python DOM interface (though any new W3C API for this would also be supported).</p> </div> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Node.appendChild"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">appendChild</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newChild</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Node.appendChild" title="Permalink to this definition">¶</a></dt> <dd><p>Add a new child node to this node at the end of the list of children, returning <em>newChild</em>. If the node was already in the tree, it is removed first.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Node.insertBefore"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">insertBefore</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newChild</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">refChild</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Node.insertBefore" title="Permalink to this definition">¶</a></dt> <dd><p>Insert a new child node before an existing child. It must be the case that <em>refChild</em> is a child of this node; if not, <code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code> is raised. <em>newChild</em> is returned. If <em>refChild</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>, it inserts <em>newChild</em> at the end of the children’s list.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Node.removeChild"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">removeChild</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">oldChild</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Node.removeChild" title="Permalink to this definition">¶</a></dt> <dd><p>Remove a child node. <em>oldChild</em> must be a child of this node; if not, <code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code> is raised. <em>oldChild</em> is returned on success. If <em>oldChild</em> will not be used further, its <code class="xref py py-meth docutils literal notranslate"><span class="pre">unlink()</span></code> method should be called.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Node.replaceChild"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">replaceChild</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newChild</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">oldChild</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Node.replaceChild" title="Permalink to this definition">¶</a></dt> <dd><p>Replace an existing node with a new node. It must be the case that <em>oldChild</em> is a child of this node; if not, <code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code> is raised.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Node.normalize"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">normalize</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Node.normalize" title="Permalink to this definition">¶</a></dt> <dd><p>Join adjacent text nodes so that all stretches of text are stored as single <code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code> instances. This simplifies processing text from a DOM tree for many applications.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 2.1.</span></p> </div> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Node.cloneNode"> <span class="sig-prename descclassname"><span class="pre">Node.</span></span><span class="sig-name descname"><span class="pre">cloneNode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">deep</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Node.cloneNode" title="Permalink to this definition">¶</a></dt> <dd><p>Clone this node. Setting <em>deep</em> means to clone all child nodes as well. This returns the clone.</p> </dd></dl> </section> <section id="nodelist-objects"> <span id="dom-nodelist-objects"></span><h3><span class="section-number">19.8.2.3. </span>NodeList Objects<a class="headerlink" href="#nodelist-objects" title="Permalink to this headline">¶</a></h3> <p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">NodeList</span></code> represents a sequence of nodes. These objects are used in two ways in the DOM Core recommendation: an <code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code> object provides one as its list of child nodes, and the <code class="xref py py-meth docutils literal notranslate"><span class="pre">getElementsByTagName()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">getElementsByTagNameNS()</span></code> methods of <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code> return objects with this interface to represent query results.</p> <p>The DOM Level 2 recommendation defines one method and one attribute for these objects:</p> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.NodeList.item"> <span class="sig-prename descclassname"><span class="pre">NodeList.</span></span><span class="sig-name descname"><span class="pre">item</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">i</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.NodeList.item" title="Permalink to this definition">¶</a></dt> <dd><p>Return the <em>i</em>’th item from the sequence, if there is one, or <code class="docutils literal notranslate"><span class="pre">None</span></code>. The index <em>i</em> is not allowed to be less than zero or greater than or equal to the length of the sequence.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.NodeList.length"> <span class="sig-prename descclassname"><span class="pre">NodeList.</span></span><span class="sig-name descname"><span class="pre">length</span></span><a class="headerlink" href="#xml.dom.NodeList.length" title="Permalink to this definition">¶</a></dt> <dd><p>The number of nodes in the sequence.</p> </dd></dl> <p>In addition, the Python DOM interface requires that some additional support is provided to allow <code class="xref py py-class docutils literal notranslate"><span class="pre">NodeList</span></code> objects to be used as Python sequences. All <code class="xref py py-class docutils literal notranslate"><span class="pre">NodeList</span></code> implementations must include support for <a class="reference internal" href="../reference/datamodel.html#object.__len__" title="object.__len__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__len__()</span></code></a> and <a class="reference internal" href="../reference/datamodel.html#object.__getitem__" title="object.__getitem__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__getitem__()</span></code></a>; this allows iteration over the <code class="xref py py-class docutils literal notranslate"><span class="pre">NodeList</span></code> in <a class="reference internal" href="../reference/compound_stmts.html#for"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">for</span></code></a> statements and proper support for the <a class="reference internal" href="functions.html#len" title="len"><code class="xref py py-func docutils literal notranslate"><span class="pre">len()</span></code></a> built-in function.</p> <p>If a DOM implementation supports modification of the document, the <code class="xref py py-class docutils literal notranslate"><span class="pre">NodeList</span></code> implementation must also support the <a class="reference internal" href="../reference/datamodel.html#object.__setitem__" title="object.__setitem__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__setitem__()</span></code></a> and <a class="reference internal" href="../reference/datamodel.html#object.__delitem__" title="object.__delitem__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__delitem__()</span></code></a> methods.</p> </section> <section id="documenttype-objects"> <span id="dom-documenttype-objects"></span><h3><span class="section-number">19.8.2.4. </span>DocumentType Objects<a class="headerlink" href="#documenttype-objects" title="Permalink to this headline">¶</a></h3> <p>Information about the notations and entities declared by a document (including the external subset if the parser uses it and can provide the information) is available from a <code class="xref py py-class docutils literal notranslate"><span class="pre">DocumentType</span></code> object. The <code class="xref py py-class docutils literal notranslate"><span class="pre">DocumentType</span></code> for a document is available from the <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> object’s <code class="xref py py-attr docutils literal notranslate"><span class="pre">doctype</span></code> attribute; if there is no <code class="docutils literal notranslate"><span class="pre">DOCTYPE</span></code> declaration for the document, the document’s <code class="xref py py-attr docutils literal notranslate"><span class="pre">doctype</span></code> attribute will be set to <code class="docutils literal notranslate"><span class="pre">None</span></code> instead of an instance of this interface.</p> <p><code class="xref py py-class docutils literal notranslate"><span class="pre">DocumentType</span></code> is a specialization of <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code>, and adds the following attributes:</p> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.DocumentType.publicId"> <span class="sig-prename descclassname"><span class="pre">DocumentType.</span></span><span class="sig-name descname"><span class="pre">publicId</span></span><a class="headerlink" href="#xml.dom.DocumentType.publicId" title="Permalink to this definition">¶</a></dt> <dd><p>The public identifier for the external subset of the document type definition. This will be a string or <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.DocumentType.systemId"> <span class="sig-prename descclassname"><span class="pre">DocumentType.</span></span><span class="sig-name descname"><span class="pre">systemId</span></span><a class="headerlink" href="#xml.dom.DocumentType.systemId" title="Permalink to this definition">¶</a></dt> <dd><p>The system identifier for the external subset of the document type definition. This will be a URI as a string, or <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.DocumentType.internalSubset"> <span class="sig-prename descclassname"><span class="pre">DocumentType.</span></span><span class="sig-name descname"><span class="pre">internalSubset</span></span><a class="headerlink" href="#xml.dom.DocumentType.internalSubset" title="Permalink to this definition">¶</a></dt> <dd><p>A string giving the complete internal subset from the document. This does not include the brackets which enclose the subset. If the document has no internal subset, this should be <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.DocumentType.name"> <span class="sig-prename descclassname"><span class="pre">DocumentType.</span></span><span class="sig-name descname"><span class="pre">name</span></span><a class="headerlink" href="#xml.dom.DocumentType.name" title="Permalink to this definition">¶</a></dt> <dd><p>The name of the root element as given in the <code class="docutils literal notranslate"><span class="pre">DOCTYPE</span></code> declaration, if present.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.DocumentType.entities"> <span class="sig-prename descclassname"><span class="pre">DocumentType.</span></span><span class="sig-name descname"><span class="pre">entities</span></span><a class="headerlink" href="#xml.dom.DocumentType.entities" title="Permalink to this definition">¶</a></dt> <dd><p>This is a <code class="xref py py-class docutils literal notranslate"><span class="pre">NamedNodeMap</span></code> giving the definitions of external entities. For entity names defined more than once, only the first definition is provided (others are ignored as required by the XML recommendation). This may be <code class="docutils literal notranslate"><span class="pre">None</span></code> if the information is not provided by the parser, or if no entities are defined.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.DocumentType.notations"> <span class="sig-prename descclassname"><span class="pre">DocumentType.</span></span><span class="sig-name descname"><span class="pre">notations</span></span><a class="headerlink" href="#xml.dom.DocumentType.notations" title="Permalink to this definition">¶</a></dt> <dd><p>This is a <code class="xref py py-class docutils literal notranslate"><span class="pre">NamedNodeMap</span></code> giving the definitions of notations. For notation names defined more than once, only the first definition is provided (others are ignored as required by the XML recommendation). This may be <code class="docutils literal notranslate"><span class="pre">None</span></code> if the information is not provided by the parser, or if no notations are defined.</p> </dd></dl> </section> <section id="document-objects"> <span id="dom-document-objects"></span><h3><span class="section-number">19.8.2.5. </span>Document Objects<a class="headerlink" href="#document-objects" title="Permalink to this headline">¶</a></h3> <p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> represents an entire XML document, including its constituent elements, attributes, processing instructions, comments etc. Remember that it inherits properties from <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code>.</p> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Document.documentElement"> <span class="sig-prename descclassname"><span class="pre">Document.</span></span><span class="sig-name descname"><span class="pre">documentElement</span></span><a class="headerlink" href="#xml.dom.Document.documentElement" title="Permalink to this definition">¶</a></dt> <dd><p>The one and only root element of the document.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Document.createElement"> <span class="sig-prename descclassname"><span class="pre">Document.</span></span><span class="sig-name descname"><span class="pre">createElement</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Document.createElement" title="Permalink to this definition">¶</a></dt> <dd><p>Create and return a new element node. The element is not inserted into the document when it is created. You need to explicitly insert it with one of the other methods such as <code class="xref py py-meth docutils literal notranslate"><span class="pre">insertBefore()</span></code> or <code class="xref py py-meth docutils literal notranslate"><span class="pre">appendChild()</span></code>.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Document.createElementNS"> <span class="sig-prename descclassname"><span class="pre">Document.</span></span><span class="sig-name descname"><span class="pre">createElementNS</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">namespaceURI</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tagName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Document.createElementNS" title="Permalink to this definition">¶</a></dt> <dd><p>Create and return a new element with a namespace. The <em>tagName</em> may have a prefix. The element is not inserted into the document when it is created. You need to explicitly insert it with one of the other methods such as <code class="xref py py-meth docutils literal notranslate"><span class="pre">insertBefore()</span></code> or <code class="xref py py-meth docutils literal notranslate"><span class="pre">appendChild()</span></code>.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Document.createTextNode"> <span class="sig-prename descclassname"><span class="pre">Document.</span></span><span class="sig-name descname"><span class="pre">createTextNode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Document.createTextNode" title="Permalink to this definition">¶</a></dt> <dd><p>Create and return a text node containing the data passed as a parameter. As with the other creation methods, this one does not insert the node into the tree.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Document.createComment"> <span class="sig-prename descclassname"><span class="pre">Document.</span></span><span class="sig-name descname"><span class="pre">createComment</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Document.createComment" title="Permalink to this definition">¶</a></dt> <dd><p>Create and return a comment node containing the data passed as a parameter. As with the other creation methods, this one does not insert the node into the tree.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Document.createProcessingInstruction"> <span class="sig-prename descclassname"><span class="pre">Document.</span></span><span class="sig-name descname"><span class="pre">createProcessingInstruction</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">target</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Document.createProcessingInstruction" title="Permalink to this definition">¶</a></dt> <dd><p>Create and return a processing instruction node containing the <em>target</em> and <em>data</em> passed as parameters. As with the other creation methods, this one does not insert the node into the tree.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Document.createAttribute"> <span class="sig-prename descclassname"><span class="pre">Document.</span></span><span class="sig-name descname"><span class="pre">createAttribute</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Document.createAttribute" title="Permalink to this definition">¶</a></dt> <dd><p>Create and return an attribute node. This method does not associate the attribute node with any particular element. You must use <code class="xref py py-meth docutils literal notranslate"><span class="pre">setAttributeNode()</span></code> on the appropriate <code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code> object to use the newly created attribute instance.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Document.createAttributeNS"> <span class="sig-prename descclassname"><span class="pre">Document.</span></span><span class="sig-name descname"><span class="pre">createAttributeNS</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">namespaceURI</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qualifiedName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Document.createAttributeNS" title="Permalink to this definition">¶</a></dt> <dd><p>Create and return an attribute node with a namespace. The <em>tagName</em> may have a prefix. This method does not associate the attribute node with any particular element. You must use <code class="xref py py-meth docutils literal notranslate"><span class="pre">setAttributeNode()</span></code> on the appropriate <code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code> object to use the newly created attribute instance.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Document.getElementsByTagName"> <span class="sig-prename descclassname"><span class="pre">Document.</span></span><span class="sig-name descname"><span class="pre">getElementsByTagName</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Document.getElementsByTagName" title="Permalink to this definition">¶</a></dt> <dd><p>Search for all descendants (direct children, children’s children, etc.) with a particular element type name.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Document.getElementsByTagNameNS"> <span class="sig-prename descclassname"><span class="pre">Document.</span></span><span class="sig-name descname"><span class="pre">getElementsByTagNameNS</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">namespaceURI</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">localName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Document.getElementsByTagNameNS" title="Permalink to this definition">¶</a></dt> <dd><p>Search for all descendants (direct children, children’s children, etc.) with a particular namespace URI and localname. The localname is the part of the namespace after the prefix.</p> </dd></dl> </section> <section id="element-objects"> <span id="dom-element-objects"></span><h3><span class="section-number">19.8.2.6. </span>Element Objects<a class="headerlink" href="#element-objects" title="Permalink to this headline">¶</a></h3> <p><code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code> is a subclass of <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code>, so inherits all the attributes of that class.</p> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Element.tagName"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">tagName</span></span><a class="headerlink" href="#xml.dom.Element.tagName" title="Permalink to this definition">¶</a></dt> <dd><p>The element type name. In a namespace-using document it may have colons in it. The value is a string.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.getElementsByTagName"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">getElementsByTagName</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tagName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.getElementsByTagName" title="Permalink to this definition">¶</a></dt> <dd><p>Same as equivalent method in the <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> class.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.getElementsByTagNameNS"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">getElementsByTagNameNS</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">namespaceURI</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">localName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.getElementsByTagNameNS" title="Permalink to this definition">¶</a></dt> <dd><p>Same as equivalent method in the <code class="xref py py-class docutils literal notranslate"><span class="pre">Document</span></code> class.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.hasAttribute"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">hasAttribute</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.hasAttribute" title="Permalink to this definition">¶</a></dt> <dd><p>Returns true if the element has an attribute named by <em>name</em>.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.hasAttributeNS"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">hasAttributeNS</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">namespaceURI</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">localName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.hasAttributeNS" title="Permalink to this definition">¶</a></dt> <dd><p>Returns true if the element has an attribute named by <em>namespaceURI</em> and <em>localName</em>.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.getAttribute"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">getAttribute</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.getAttribute" title="Permalink to this definition">¶</a></dt> <dd><p>Return the value of the attribute named by <em>name</em> as a string. If no such attribute exists, an empty string is returned, as if the attribute had no value.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.getAttributeNode"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">getAttributeNode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">attrname</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.getAttributeNode" title="Permalink to this definition">¶</a></dt> <dd><p>Return the <code class="xref py py-class docutils literal notranslate"><span class="pre">Attr</span></code> node for the attribute named by <em>attrname</em>.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.getAttributeNS"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">getAttributeNS</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">namespaceURI</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">localName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.getAttributeNS" title="Permalink to this definition">¶</a></dt> <dd><p>Return the value of the attribute named by <em>namespaceURI</em> and <em>localName</em> as a string. If no such attribute exists, an empty string is returned, as if the attribute had no value.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.getAttributeNodeNS"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">getAttributeNodeNS</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">namespaceURI</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">localName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.getAttributeNodeNS" title="Permalink to this definition">¶</a></dt> <dd><p>Return an attribute value as a node, given a <em>namespaceURI</em> and <em>localName</em>.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.removeAttribute"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">removeAttribute</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.removeAttribute" title="Permalink to this definition">¶</a></dt> <dd><p>Remove an attribute by name. If there is no matching attribute, a <a class="reference internal" href="#xml.dom.NotFoundErr" title="xml.dom.NotFoundErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">NotFoundErr</span></code></a> is raised.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.removeAttributeNode"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">removeAttributeNode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">oldAttr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.removeAttributeNode" title="Permalink to this definition">¶</a></dt> <dd><p>Remove and return <em>oldAttr</em> from the attribute list, if present. If <em>oldAttr</em> is not present, <a class="reference internal" href="#xml.dom.NotFoundErr" title="xml.dom.NotFoundErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">NotFoundErr</span></code></a> is raised.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.removeAttributeNS"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">removeAttributeNS</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">namespaceURI</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">localName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.removeAttributeNS" title="Permalink to this definition">¶</a></dt> <dd><p>Remove an attribute by name. Note that it uses a localName, not a qname. No exception is raised if there is no matching attribute.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.setAttribute"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">setAttribute</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.setAttribute" title="Permalink to this definition">¶</a></dt> <dd><p>Set an attribute value from a string.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.setAttributeNode"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">setAttributeNode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newAttr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.setAttributeNode" title="Permalink to this definition">¶</a></dt> <dd><p>Add a new attribute node to the element, replacing an existing attribute if necessary if the <code class="xref py py-attr docutils literal notranslate"><span class="pre">name</span></code> attribute matches. If a replacement occurs, the old attribute node will be returned. If <em>newAttr</em> is already in use, <a class="reference internal" href="#xml.dom.InuseAttributeErr" title="xml.dom.InuseAttributeErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InuseAttributeErr</span></code></a> will be raised.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.setAttributeNodeNS"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">setAttributeNodeNS</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">newAttr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.setAttributeNodeNS" title="Permalink to this definition">¶</a></dt> <dd><p>Add a new attribute node to the element, replacing an existing attribute if necessary if the <code class="xref py py-attr docutils literal notranslate"><span class="pre">namespaceURI</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">localName</span></code> attributes match. If a replacement occurs, the old attribute node will be returned. If <em>newAttr</em> is already in use, <a class="reference internal" href="#xml.dom.InuseAttributeErr" title="xml.dom.InuseAttributeErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InuseAttributeErr</span></code></a> will be raised.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.Element.setAttributeNS"> <span class="sig-prename descclassname"><span class="pre">Element.</span></span><span class="sig-name descname"><span class="pre">setAttributeNS</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">namespaceURI</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.Element.setAttributeNS" title="Permalink to this definition">¶</a></dt> <dd><p>Set an attribute value from a string, given a <em>namespaceURI</em> and a <em>qname</em>. Note that a qname is the whole attribute name. This is different than above.</p> </dd></dl> </section> <section id="attr-objects"> <span id="dom-attr-objects"></span><h3><span class="section-number">19.8.2.7. </span>Attr Objects<a class="headerlink" href="#attr-objects" title="Permalink to this headline">¶</a></h3> <p><code class="xref py py-class docutils literal notranslate"><span class="pre">Attr</span></code> inherits from <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code>, so inherits all its attributes.</p> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Attr.name"> <span class="sig-prename descclassname"><span class="pre">Attr.</span></span><span class="sig-name descname"><span class="pre">name</span></span><a class="headerlink" href="#xml.dom.Attr.name" title="Permalink to this definition">¶</a></dt> <dd><p>The attribute name. In a namespace-using document it may include a colon.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Attr.localName"> <span class="sig-prename descclassname"><span class="pre">Attr.</span></span><span class="sig-name descname"><span class="pre">localName</span></span><a class="headerlink" href="#xml.dom.Attr.localName" title="Permalink to this definition">¶</a></dt> <dd><p>The part of the name following the colon if there is one, else the entire name. This is a read-only attribute.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Attr.prefix"> <span class="sig-prename descclassname"><span class="pre">Attr.</span></span><span class="sig-name descname"><span class="pre">prefix</span></span><a class="headerlink" href="#xml.dom.Attr.prefix" title="Permalink to this definition">¶</a></dt> <dd><p>The part of the name preceding the colon if there is one, else the empty string.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Attr.value"> <span class="sig-prename descclassname"><span class="pre">Attr.</span></span><span class="sig-name descname"><span class="pre">value</span></span><a class="headerlink" href="#xml.dom.Attr.value" title="Permalink to this definition">¶</a></dt> <dd><p>The text value of the attribute. This is a synonym for the <code class="xref py py-attr docutils literal notranslate"><span class="pre">nodeValue</span></code> attribute.</p> </dd></dl> </section> <section id="namednodemap-objects"> <span id="dom-attributelist-objects"></span><h3><span class="section-number">19.8.2.8. </span>NamedNodeMap Objects<a class="headerlink" href="#namednodemap-objects" title="Permalink to this headline">¶</a></h3> <p><code class="xref py py-class docutils literal notranslate"><span class="pre">NamedNodeMap</span></code> does <em>not</em> inherit from <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code>.</p> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.NamedNodeMap.length"> <span class="sig-prename descclassname"><span class="pre">NamedNodeMap.</span></span><span class="sig-name descname"><span class="pre">length</span></span><a class="headerlink" href="#xml.dom.NamedNodeMap.length" title="Permalink to this definition">¶</a></dt> <dd><p>The length of the attribute list.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.dom.NamedNodeMap.item"> <span class="sig-prename descclassname"><span class="pre">NamedNodeMap.</span></span><span class="sig-name descname"><span class="pre">item</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.dom.NamedNodeMap.item" title="Permalink to this definition">¶</a></dt> <dd><p>Return an attribute with a particular index. The order you get the attributes in is arbitrary but will be consistent for the life of a DOM. Each item is an attribute node. Get its value with the <code class="xref py py-attr docutils literal notranslate"><span class="pre">value</span></code> attribute.</p> </dd></dl> <p>There are also experimental methods that give this class more mapping behavior. You can use them or you can use the standardized <code class="xref py py-meth docutils literal notranslate"><span class="pre">getAttribute*()</span></code> family of methods on the <code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code> objects.</p> </section> <section id="comment-objects"> <span id="dom-comment-objects"></span><h3><span class="section-number">19.8.2.9. </span>Comment Objects<a class="headerlink" href="#comment-objects" title="Permalink to this headline">¶</a></h3> <p><code class="xref py py-class docutils literal notranslate"><span class="pre">Comment</span></code> represents a comment in the XML document. It is a subclass of <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code>, but cannot have child nodes.</p> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Comment.data"> <span class="sig-prename descclassname"><span class="pre">Comment.</span></span><span class="sig-name descname"><span class="pre">data</span></span><a class="headerlink" href="#xml.dom.Comment.data" title="Permalink to this definition">¶</a></dt> <dd><p>The content of the comment as a string. The attribute contains all characters between the leading <code class="docutils literal notranslate"><span class="pre"><!-</span></code><code class="docutils literal notranslate"><span class="pre">-</span></code> and trailing <code class="docutils literal notranslate"><span class="pre">-</span></code><code class="docutils literal notranslate"><span class="pre">-></span></code>, but does not include them.</p> </dd></dl> </section> <section id="text-and-cdatasection-objects"> <span id="dom-text-objects"></span><h3><span class="section-number">19.8.2.10. </span>Text and CDATASection Objects<a class="headerlink" href="#text-and-cdatasection-objects" title="Permalink to this headline">¶</a></h3> <p>The <code class="xref py py-class docutils literal notranslate"><span class="pre">Text</span></code> interface represents text in the XML document. If the parser and DOM implementation support the DOM’s XML extension, portions of the text enclosed in CDATA marked sections are stored in <code class="xref py py-class docutils literal notranslate"><span class="pre">CDATASection</span></code> objects. These two interfaces are identical, but provide different values for the <code class="xref py py-attr docutils literal notranslate"><span class="pre">nodeType</span></code> attribute.</p> <p>These interfaces extend the <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code> interface. They cannot have child nodes.</p> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.Text.data"> <span class="sig-prename descclassname"><span class="pre">Text.</span></span><span class="sig-name descname"><span class="pre">data</span></span><a class="headerlink" href="#xml.dom.Text.data" title="Permalink to this definition">¶</a></dt> <dd><p>The content of the text node as a string.</p> </dd></dl> <div class="admonition note"> <p class="admonition-title">Note</p> <p>The use of a <code class="xref py py-class docutils literal notranslate"><span class="pre">CDATASection</span></code> node does not indicate that the node represents a complete CDATA marked section, only that the content of the node was part of a CDATA section. A single CDATA section may be represented by more than one node in the document tree. There is no way to determine whether two adjacent <code class="xref py py-class docutils literal notranslate"><span class="pre">CDATASection</span></code> nodes represent different CDATA marked sections.</p> </div> </section> <section id="processinginstruction-objects"> <span id="dom-pi-objects"></span><h3><span class="section-number">19.8.2.11. </span>ProcessingInstruction Objects<a class="headerlink" href="#processinginstruction-objects" title="Permalink to this headline">¶</a></h3> <p>Represents a processing instruction in the XML document; this inherits from the <code class="xref py py-class docutils literal notranslate"><span class="pre">Node</span></code> interface and cannot have child nodes.</p> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.ProcessingInstruction.target"> <span class="sig-prename descclassname"><span class="pre">ProcessingInstruction.</span></span><span class="sig-name descname"><span class="pre">target</span></span><a class="headerlink" href="#xml.dom.ProcessingInstruction.target" title="Permalink to this definition">¶</a></dt> <dd><p>The content of the processing instruction up to the first whitespace character. This is a read-only attribute.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.dom.ProcessingInstruction.data"> <span class="sig-prename descclassname"><span class="pre">ProcessingInstruction.</span></span><span class="sig-name descname"><span class="pre">data</span></span><a class="headerlink" href="#xml.dom.ProcessingInstruction.data" title="Permalink to this definition">¶</a></dt> <dd><p>The content of the processing instruction following the first whitespace character.</p> </dd></dl> </section> <section id="exceptions"> <span id="dom-exceptions"></span><h3><span class="section-number">19.8.2.12. </span>Exceptions<a class="headerlink" href="#exceptions" title="Permalink to this headline">¶</a></h3> <div class="versionadded"> <p><span class="versionmodified added">New in version 2.1.</span></p> </div> <p>The DOM Level 2 recommendation defines a single exception, <a class="reference internal" href="#xml.dom.DOMException" title="xml.dom.DOMException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DOMException</span></code></a>, and a number of constants that allow applications to determine what sort of error occurred. <a class="reference internal" href="#xml.dom.DOMException" title="xml.dom.DOMException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DOMException</span></code></a> instances carry a <a class="reference internal" href="code.html#module-code" title="code: Facilities to implement read-eval-print loops."><code class="xref py py-attr docutils literal notranslate"><span class="pre">code</span></code></a> attribute that provides the appropriate value for the specific exception.</p> <p>The Python DOM interface provides the constants, but also expands the set of exceptions so that a specific exception exists for each of the exception codes defined by the DOM. The implementations must raise the appropriate specific exception, each of which carries the appropriate value for the <a class="reference internal" href="code.html#module-code" title="code: Facilities to implement read-eval-print loops."><code class="xref py py-attr docutils literal notranslate"><span class="pre">code</span></code></a> attribute.</p> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.DOMException"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">DOMException</span></span><a class="headerlink" href="#xml.dom.DOMException" title="Permalink to this definition">¶</a></dt> <dd><p>Base exception class used for all specific DOM exceptions. This exception class cannot be directly instantiated.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.DomstringSizeErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">DomstringSizeErr</span></span><a class="headerlink" href="#xml.dom.DomstringSizeErr" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a specified range of text does not fit into a string. This is not known to be used in the Python DOM implementations, but may be received from DOM implementations not written in Python.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.HierarchyRequestErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">HierarchyRequestErr</span></span><a class="headerlink" href="#xml.dom.HierarchyRequestErr" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when an attempt is made to insert a node where the node type is not allowed.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.IndexSizeErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">IndexSizeErr</span></span><a class="headerlink" href="#xml.dom.IndexSizeErr" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when an index or size parameter to a method is negative or exceeds the allowed values.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.InuseAttributeErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">InuseAttributeErr</span></span><a class="headerlink" href="#xml.dom.InuseAttributeErr" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when an attempt is made to insert an <code class="xref py py-class docutils literal notranslate"><span class="pre">Attr</span></code> node that is already present elsewhere in the document.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.InvalidAccessErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">InvalidAccessErr</span></span><a class="headerlink" href="#xml.dom.InvalidAccessErr" title="Permalink to this definition">¶</a></dt> <dd><p>Raised if a parameter or an operation is not supported on the underlying object.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.InvalidCharacterErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">InvalidCharacterErr</span></span><a class="headerlink" href="#xml.dom.InvalidCharacterErr" title="Permalink to this definition">¶</a></dt> <dd><p>This exception is raised when a string parameter contains a character that is not permitted in the context it’s being used in by the XML 1.0 recommendation. For example, attempting to create an <code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code> node with a space in the element type name will cause this error to be raised.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.InvalidModificationErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">InvalidModificationErr</span></span><a class="headerlink" href="#xml.dom.InvalidModificationErr" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when an attempt is made to modify the type of a node.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.InvalidStateErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">InvalidStateErr</span></span><a class="headerlink" href="#xml.dom.InvalidStateErr" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when an attempt is made to use an object that is not defined or is no longer usable.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.NamespaceErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">NamespaceErr</span></span><a class="headerlink" href="#xml.dom.NamespaceErr" title="Permalink to this definition">¶</a></dt> <dd><p>If an attempt is made to change any object in a way that is not permitted with regard to the <a class="reference external" href="https://www.w3.org/TR/REC-xml-names/">Namespaces in XML</a> recommendation, this exception is raised.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.NotFoundErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">NotFoundErr</span></span><a class="headerlink" href="#xml.dom.NotFoundErr" title="Permalink to this definition">¶</a></dt> <dd><p>Exception when a node does not exist in the referenced context. For example, <code class="xref py py-meth docutils literal notranslate"><span class="pre">NamedNodeMap.removeNamedItem()</span></code> will raise this if the node passed in does not exist in the map.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.NotSupportedErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">NotSupportedErr</span></span><a class="headerlink" href="#xml.dom.NotSupportedErr" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when the implementation does not support the requested type of object or operation.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.NoDataAllowedErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">NoDataAllowedErr</span></span><a class="headerlink" href="#xml.dom.NoDataAllowedErr" title="Permalink to this definition">¶</a></dt> <dd><p>This is raised if data is specified for a node which does not support data.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.NoModificationAllowedErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">NoModificationAllowedErr</span></span><a class="headerlink" href="#xml.dom.NoModificationAllowedErr" title="Permalink to this definition">¶</a></dt> <dd><p>Raised on attempts to modify an object where modifications are not allowed (such as for read-only nodes).</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.SyntaxErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">SyntaxErr</span></span><a class="headerlink" href="#xml.dom.SyntaxErr" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when an invalid or illegal string is specified.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.dom.WrongDocumentErr"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.dom.</span></span><span class="sig-name descname"><span class="pre">WrongDocumentErr</span></span><a class="headerlink" href="#xml.dom.WrongDocumentErr" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when a node is inserted in a different document than it currently belongs to, and the implementation does not support migrating the node from one document to the other.</p> </dd></dl> <p>The exception codes defined in the DOM recommendation map to the exceptions described above according to this table:</p> <table class="docutils align-default"> <colgroup> <col style="width: 54%" /> <col style="width: 46%" /> </colgroup> <thead> <tr class="row-odd"><th class="head"><p>Constant</p></th> <th class="head"><p>Exception</p></th> </tr> </thead> <tbody> <tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">DOMSTRING_SIZE_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.DomstringSizeErr" title="xml.dom.DomstringSizeErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DomstringSizeErr</span></code></a></p></td> </tr> <tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">HIERARCHY_REQUEST_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.HierarchyRequestErr" title="xml.dom.HierarchyRequestErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">HierarchyRequestErr</span></code></a></p></td> </tr> <tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">INDEX_SIZE_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.IndexSizeErr" title="xml.dom.IndexSizeErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IndexSizeErr</span></code></a></p></td> </tr> <tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">INUSE_ATTRIBUTE_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.InuseAttributeErr" title="xml.dom.InuseAttributeErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InuseAttributeErr</span></code></a></p></td> </tr> <tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">INVALID_ACCESS_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.InvalidAccessErr" title="xml.dom.InvalidAccessErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InvalidAccessErr</span></code></a></p></td> </tr> <tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">INVALID_CHARACTER_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.InvalidCharacterErr" title="xml.dom.InvalidCharacterErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InvalidCharacterErr</span></code></a></p></td> </tr> <tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">INVALID_MODIFICATION_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.InvalidModificationErr" title="xml.dom.InvalidModificationErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InvalidModificationErr</span></code></a></p></td> </tr> <tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">INVALID_STATE_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.InvalidStateErr" title="xml.dom.InvalidStateErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InvalidStateErr</span></code></a></p></td> </tr> <tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">NAMESPACE_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.NamespaceErr" title="xml.dom.NamespaceErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">NamespaceErr</span></code></a></p></td> </tr> <tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">NOT_FOUND_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.NotFoundErr" title="xml.dom.NotFoundErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">NotFoundErr</span></code></a></p></td> </tr> <tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">NOT_SUPPORTED_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.NotSupportedErr" title="xml.dom.NotSupportedErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">NotSupportedErr</span></code></a></p></td> </tr> <tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">NO_DATA_ALLOWED_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.NoDataAllowedErr" title="xml.dom.NoDataAllowedErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">NoDataAllowedErr</span></code></a></p></td> </tr> <tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">NO_MODIFICATION_ALLOWED_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.NoModificationAllowedErr" title="xml.dom.NoModificationAllowedErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">NoModificationAllowedErr</span></code></a></p></td> </tr> <tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">SYNTAX_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.SyntaxErr" title="xml.dom.SyntaxErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxErr</span></code></a></p></td> </tr> <tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">WRONG_DOCUMENT_ERR</span></code></p></td> <td><p><a class="reference internal" href="#xml.dom.WrongDocumentErr" title="xml.dom.WrongDocumentErr"><code class="xref py py-exc docutils literal notranslate"><span class="pre">WrongDocumentErr</span></code></a></p></td> </tr> </tbody> </table> </section> </section> <section id="conformance"> <span id="dom-conformance"></span><h2><span class="section-number">19.8.3. </span>Conformance<a class="headerlink" href="#conformance" title="Permalink to this headline">¶</a></h2> <p>This section describes the conformance requirements and relationships between the Python DOM API, the W3C DOM recommendations, and the OMG IDL mapping for Python.</p> <section id="type-mapping"> <span id="dom-type-mapping"></span><h3><span class="section-number">19.8.3.1. </span>Type Mapping<a class="headerlink" href="#type-mapping" title="Permalink to this headline">¶</a></h3> <p>The primitive IDL types used in the DOM specification are mapped to Python types according to the following table.</p> <table class="docutils align-default"> <colgroup> <col style="width: 30%" /> <col style="width: 70%" /> </colgroup> <thead> <tr class="row-odd"><th class="head"><p>IDL Type</p></th> <th class="head"><p>Python Type</p></th> </tr> </thead> <tbody> <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">boolean</span></code></p></td> <td><p><code class="docutils literal notranslate"><span class="pre">IntegerType</span></code> (with a value of <code class="docutils literal notranslate"><span class="pre">0</span></code> or <code class="docutils literal notranslate"><span class="pre">1</span></code>)</p></td> </tr> <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">int</span></code></p></td> <td><p><code class="docutils literal notranslate"><span class="pre">IntegerType</span></code></p></td> </tr> <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">long</span> <span class="pre">int</span></code></p></td> <td><p><code class="docutils literal notranslate"><span class="pre">IntegerType</span></code></p></td> </tr> <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">int</span></code></p></td> <td><p><code class="docutils literal notranslate"><span class="pre">IntegerType</span></code></p></td> </tr> </tbody> </table> <p>Additionally, the <code class="xref py py-class docutils literal notranslate"><span class="pre">DOMString</span></code> defined in the recommendation is mapped to a Python string or Unicode string. Applications should be able to handle Unicode whenever a string is returned from the DOM.</p> <p>The IDL <code class="docutils literal notranslate"><span class="pre">null</span></code> value is mapped to <code class="docutils literal notranslate"><span class="pre">None</span></code>, which may be accepted or provided by the implementation whenever <code class="docutils literal notranslate"><span class="pre">null</span></code> is allowed by the API.</p> </section> <section id="accessor-methods"> <span id="dom-accessor-methods"></span><h3><span class="section-number">19.8.3.2. </span>Accessor Methods<a class="headerlink" href="#accessor-methods" title="Permalink to this headline">¶</a></h3> <p>The mapping from OMG IDL to Python defines accessor functions for IDL <code class="docutils literal notranslate"><span class="pre">attribute</span></code> declarations in much the way the Java mapping does. Mapping the IDL declarations</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">readonly</span> <span class="n">attribute</span> <span class="n">string</span> <span class="n">someValue</span><span class="p">;</span> <span class="n">attribute</span> <span class="n">string</span> <span class="n">anotherValue</span><span class="p">;</span> </pre></div> </div> <p>yields three accessor functions: a “get” method for <code class="xref py py-attr docutils literal notranslate"><span class="pre">someValue</span></code> (<code class="xref py py-meth docutils literal notranslate"><span class="pre">_get_someValue()</span></code>), and “get” and “set” methods for <code class="xref py py-attr docutils literal notranslate"><span class="pre">anotherValue</span></code> (<code class="xref py py-meth docutils literal notranslate"><span class="pre">_get_anotherValue()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">_set_anotherValue()</span></code>). The mapping, in particular, does not require that the IDL attributes are accessible as normal Python attributes: <code class="docutils literal notranslate"><span class="pre">object.someValue</span></code> is <em>not</em> required to work, and may raise an <code class="xref py py-exc docutils literal notranslate"><span class="pre">AttributeError</span></code>.</p> <p>The Python DOM API, however, <em>does</em> require that normal attribute access work. This means that the typical surrogates generated by Python IDL compilers are not likely to work, and wrapper objects may be needed on the client if the DOM objects are accessed via CORBA. While this does require some additional consideration for CORBA DOM clients, the implementers with experience using DOM over CORBA from Python do not consider this a problem. Attributes that are declared <code class="docutils literal notranslate"><span class="pre">readonly</span></code> may not restrict write access in all DOM implementations.</p> <p>In the Python DOM API, accessor functions are not required. If provided, they should take the form defined by the Python IDL mapping, but these methods are considered unnecessary since the attributes are accessible directly from Python. “Set” accessors should never be provided for <code class="docutils literal notranslate"><span class="pre">readonly</span></code> attributes.</p> <p>The IDL definitions do not fully embody the requirements of the W3C DOM API, such as the notion of certain objects, such as the return value of <code class="xref py py-meth docutils literal notranslate"><span class="pre">getElementsByTagName()</span></code>, being “live”. The Python DOM API does not require implementations to enforce such requirements.</p> </section> </section> </section> <div class="clearer"></div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table of Contents</a></h3> <ul> <li><a class="reference internal" href="#">19.8. <code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom</span></code> — The Document Object Model API</a><ul> <li><a class="reference internal" href="#module-contents">19.8.1. Module Contents</a></li> <li><a class="reference internal" href="#objects-in-the-dom">19.8.2. Objects in the DOM</a><ul> <li><a class="reference internal" href="#domimplementation-objects">19.8.2.1. DOMImplementation Objects</a></li> <li><a class="reference internal" href="#node-objects">19.8.2.2. Node Objects</a></li> <li><a class="reference internal" href="#nodelist-objects">19.8.2.3. NodeList Objects</a></li> <li><a class="reference internal" href="#documenttype-objects">19.8.2.4. DocumentType Objects</a></li> <li><a class="reference internal" href="#document-objects">19.8.2.5. Document Objects</a></li> <li><a class="reference internal" href="#element-objects">19.8.2.6. Element Objects</a></li> <li><a class="reference internal" href="#attr-objects">19.8.2.7. Attr Objects</a></li> <li><a class="reference internal" href="#namednodemap-objects">19.8.2.8. NamedNodeMap Objects</a></li> <li><a class="reference internal" href="#comment-objects">19.8.2.9. Comment Objects</a></li> <li><a class="reference internal" href="#text-and-cdatasection-objects">19.8.2.10. Text and CDATASection Objects</a></li> <li><a class="reference internal" href="#processinginstruction-objects">19.8.2.11. ProcessingInstruction Objects</a></li> <li><a class="reference internal" href="#exceptions">19.8.2.12. Exceptions</a></li> </ul> </li> <li><a class="reference internal" href="#conformance">19.8.3. Conformance</a><ul> <li><a class="reference internal" href="#type-mapping">19.8.3.1. Type Mapping</a></li> <li><a class="reference internal" href="#accessor-methods">19.8.3.2. Accessor Methods</a></li> </ul> </li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="xml.etree.elementtree.html" title="previous chapter"><span class="section-number">19.7. </span><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.etree.ElementTree</span></code> — The ElementTree XML API</a></p> <h4>Next topic</h4> <p class="topless"><a href="xml.dom.minidom.html" title="next chapter"><span class="section-number">19.9. </span><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code> — Minimal DOM implementation</a></p> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/library/xml.dom.rst.txt" rel="nofollow">Show Source</a></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="../search.html" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/> <input type="submit" value="Go" /> </form> </div> </div> <script>$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="xml.dom.minidom.html" title="19.9. xml.dom.minidom — Minimal DOM implementation" >next</a> |</li> <li class="right" > <a href="xml.etree.elementtree.html" title="19.7. xml.etree.ElementTree — The ElementTree XML API" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.18 documentation</a> » </li> <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li> <li class="nav-item nav-item-2"><a href="markup.html" ><span class="section-number">19. </span>Structured Markup Processing Tools</a> »</li> <li class="nav-item nav-item-this"><a href=""><span class="section-number">19.8. </span><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom</span></code> — The Document Object Model API</a></li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2024, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="https://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on December 09, 2024. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 4.3.2. </div> </body> </html>
Close