Linux iad1-shared-b7-18 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
Apache
: 67.205.6.31 | : 216.73.216.47
Cant Read [ /etc/named.conf ]
8.2.29
fernandoquevedo
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
README
+ Create Folder
+ Create File
/
usr /
share /
doc /
python3.10 /
html /
library /
[ HOME SHELL ]
Name
Size
Permission
Action
2to3.html
70.96
KB
-rw-r--r--
__future__.html
20.75
KB
-rw-r--r--
__main__.html
44.87
KB
-rw-r--r--
_thread.html
30.39
KB
-rw-r--r--
abc.html
46.87
KB
-rw-r--r--
aifc.html
35.56
KB
-rw-r--r--
allos.html
34.33
KB
-rw-r--r--
archiving.html
17
KB
-rw-r--r--
argparse.html
300.89
KB
-rw-r--r--
array.html
37.28
KB
-rw-r--r--
ast.html
293.08
KB
-rw-r--r--
asynchat.html
37.41
KB
-rw-r--r--
asyncio-api-index.html
27.68
KB
-rw-r--r--
asyncio-dev.html
36.1
KB
-rw-r--r--
asyncio-eventloop.html
204.43
KB
-rw-r--r--
asyncio-exceptions.html
17.11
KB
-rw-r--r--
asyncio-future.html
38.23
KB
-rw-r--r--
asyncio-llapi-index.html
61.97
KB
-rw-r--r--
asyncio-platforms.html
21.77
KB
-rw-r--r--
asyncio-policy.html
39.56
KB
-rw-r--r--
asyncio-protocol.html
118.33
KB
-rw-r--r--
asyncio-queue.html
31.86
KB
-rw-r--r--
asyncio-stream.html
69.98
KB
-rw-r--r--
asyncio-subprocess.html
49.25
KB
-rw-r--r--
asyncio-sync.html
42.79
KB
-rw-r--r--
asyncio-task.html
109.14
KB
-rw-r--r--
asyncio.html
17.31
KB
-rw-r--r--
asyncore.html
49.36
KB
-rw-r--r--
atexit.html
22.87
KB
-rw-r--r--
audioop.html
46
KB
-rw-r--r--
audit_events.html
72.85
KB
-rw-r--r--
base64.html
48.09
KB
-rw-r--r--
bdb.html
66
KB
-rw-r--r--
binary.html
15.97
KB
-rw-r--r--
binascii.html
36.3
KB
-rw-r--r--
binhex.html
15.97
KB
-rw-r--r--
bisect.html
43.38
KB
-rw-r--r--
builtins.html
14.87
KB
-rw-r--r--
bz2.html
50.68
KB
-rw-r--r--
calendar.html
69.35
KB
-rw-r--r--
cgi.html
59.95
KB
-rw-r--r--
cgitb.html
19.96
KB
-rw-r--r--
chunk.html
22.21
KB
-rw-r--r--
cmath.html
43.89
KB
-rw-r--r--
cmd.html
50.42
KB
-rw-r--r--
code.html
35.38
KB
-rw-r--r--
codecs.html
157.96
KB
-rw-r--r--
codeop.html
18.26
KB
-rw-r--r--
collections.abc.html
79.17
KB
-rw-r--r--
collections.html
189.43
KB
-rw-r--r--
colorsys.html
17.31
KB
-rw-r--r--
compileall.html
50.68
KB
-rw-r--r--
concurrency.html
24.15
KB
-rw-r--r--
concurrent.futures.html
79.03
KB
-rw-r--r--
concurrent.html
11.56
KB
-rw-r--r--
configparser.html
159.4
KB
-rw-r--r--
constants.html
22.41
KB
-rw-r--r--
contextlib.html
117.2
KB
-rw-r--r--
contextvars.html
38.38
KB
-rw-r--r--
copy.html
17.92
KB
-rw-r--r--
copyreg.html
18.63
KB
-rw-r--r--
crypt.html
28.29
KB
-rw-r--r--
crypto.html
13.93
KB
-rw-r--r--
csv.html
82.89
KB
-rw-r--r--
ctypes.html
295.49
KB
-rw-r--r--
curses.ascii.html
32.04
KB
-rw-r--r--
curses.html
221.24
KB
-rw-r--r--
curses.panel.html
22.16
KB
-rw-r--r--
custominterp.html
11.85
KB
-rw-r--r--
dataclasses.html
113.16
KB
-rw-r--r--
datatypes.html
31.82
KB
-rw-r--r--
datetime.html
374.92
KB
-rw-r--r--
dbm.html
51.16
KB
-rw-r--r--
debug.html
17
KB
-rw-r--r--
decimal.html
270.12
KB
-rw-r--r--
development.html
32.34
KB
-rw-r--r--
devmode.html
31.72
KB
-rw-r--r--
dialog.html
43.03
KB
-rw-r--r--
difflib.html
111.99
KB
-rw-r--r--
dis.html
136.07
KB
-rw-r--r--
distribution.html
13.67
KB
-rw-r--r--
distutils.html
14.73
KB
-rw-r--r--
doctest.html
199.32
KB
-rw-r--r--
email.charset.html
31.92
KB
-rw-r--r--
email.compat32-message.html
97.74
KB
-rw-r--r--
email.contentmanager.html
37.02
KB
-rw-r--r--
email.encoders.html
18.47
KB
-rw-r--r--
email.errors.html
24.45
KB
-rw-r--r--
email.examples.html
60.49
KB
-rw-r--r--
email.generator.html
48.79
KB
-rw-r--r--
email.header.html
37.61
KB
-rw-r--r--
email.headerregistry.html
66.26
KB
-rw-r--r--
email.html
30.75
KB
-rw-r--r--
email.iterators.html
18.23
KB
-rw-r--r--
email.message.html
99.75
KB
-rw-r--r--
email.mime.html
44.89
KB
-rw-r--r--
email.parser.html
57.39
KB
-rw-r--r--
email.policy.html
84.24
KB
-rw-r--r--
email.utils.html
42.57
KB
-rw-r--r--
ensurepip.html
23.9
KB
-rw-r--r--
enum.html
151
KB
-rw-r--r--
errno.html
60.17
KB
-rw-r--r--
exceptions.html
108.44
KB
-rw-r--r--
faulthandler.html
31.5
KB
-rw-r--r--
fcntl.html
36.67
KB
-rw-r--r--
filecmp.html
32.08
KB
-rw-r--r--
fileformats.html
13.52
KB
-rw-r--r--
fileinput.html
40.37
KB
-rw-r--r--
filesys.html
16.78
KB
-rw-r--r--
fnmatch.html
21.02
KB
-rw-r--r--
fractions.html
35.29
KB
-rw-r--r--
frameworks.html
16.15
KB
-rw-r--r--
ftplib.html
71.97
KB
-rw-r--r--
functional.html
12.19
KB
-rw-r--r--
functions.html
260.33
KB
-rw-r--r--
functools.html
92.96
KB
-rw-r--r--
gc.html
40.97
KB
-rw-r--r--
getopt.html
29.4
KB
-rw-r--r--
getpass.html
16.01
KB
-rw-r--r--
gettext.html
98.02
KB
-rw-r--r--
glob.html
27.2
KB
-rw-r--r--
graphlib.html
34.82
KB
-rw-r--r--
grp.html
16.03
KB
-rw-r--r--
gzip.html
45.65
KB
-rw-r--r--
hashlib.html
93.19
KB
-rw-r--r--
heapq.html
42.43
KB
-rw-r--r--
hmac.html
24.74
KB
-rw-r--r--
html.entities.html
14.91
KB
-rw-r--r--
html.html
14.81
KB
-rw-r--r--
html.parser.html
47.7
KB
-rw-r--r--
http.client.html
85.63
KB
-rw-r--r--
http.cookiejar.html
113.94
KB
-rw-r--r--
http.cookies.html
47.64
KB
-rw-r--r--
http.html
45.52
KB
-rw-r--r--
http.server.html
73.05
KB
-rw-r--r--
i18n.html
13.44
KB
-rw-r--r--
idle.html
77.18
KB
-rw-r--r--
imaplib.html
87.08
KB
-rw-r--r--
imghdr.html
17.94
KB
-rw-r--r--
imp.html
54.32
KB
-rw-r--r--
importlib.html
239.96
KB
-rw-r--r--
importlib.metadata.html
43.14
KB
-rw-r--r--
index.html
75.06
KB
-rw-r--r--
inspect.html
168.74
KB
-rw-r--r--
internet.html
29.89
KB
-rw-r--r--
intro.html
13.81
KB
-rw-r--r--
io.html
154.15
KB
-rw-r--r--
ipaddress.html
137.75
KB
-rw-r--r--
ipc.html
12.6
KB
-rw-r--r--
itertools.html
153.27
KB
-rw-r--r--
json.html
98.9
KB
-rw-r--r--
keyword.html
14.88
KB
-rw-r--r--
language.html
16.71
KB
-rw-r--r--
linecache.html
18.09
KB
-rw-r--r--
locale.html
77.35
KB
-rw-r--r--
logging.config.html
100.3
KB
-rw-r--r--
logging.handlers.html
146.28
KB
-rw-r--r--
logging.html
169.67
KB
-rw-r--r--
lzma.html
66.89
KB
-rw-r--r--
mailbox.html
176.34
KB
-rw-r--r--
mailcap.html
20.86
KB
-rw-r--r--
markup.html
22.31
KB
-rw-r--r--
marshal.html
24.43
KB
-rw-r--r--
math.html
85.82
KB
-rw-r--r--
mimetypes.html
40.27
KB
-rw-r--r--
mm.html
11.16
KB
-rw-r--r--
mmap.html
55.53
KB
-rw-r--r--
modulefinder.html
23.67
KB
-rw-r--r--
modules.html
15.88
KB
-rw-r--r--
msilib.html
78.38
KB
-rw-r--r--
msvcrt.html
29.22
KB
-rw-r--r--
multiprocessing.html
405.24
KB
-rw-r--r--
multiprocessing.shared_memory....
60
KB
-rw-r--r--
netdata.html
20.24
KB
-rw-r--r--
netrc.html
20.39
KB
-rw-r--r--
nis.html
16.76
KB
-rw-r--r--
nntplib.html
84.93
KB
-rw-r--r--
numbers.html
45.67
KB
-rw-r--r--
numeric.html
19.29
KB
-rw-r--r--
operator.html
107.32
KB
-rw-r--r--
optparse.html
256.96
KB
-rw-r--r--
os.html
594.39
KB
-rw-r--r--
os.path.html
65.54
KB
-rw-r--r--
ossaudiodev.html
56.35
KB
-rw-r--r--
pathlib.html
170.01
KB
-rw-r--r--
pdb.html
68.67
KB
-rw-r--r--
persistence.html
19.13
KB
-rw-r--r--
pickle.html
154.45
KB
-rw-r--r--
pickletools.html
22.92
KB
-rw-r--r--
pipes.html
21.7
KB
-rw-r--r--
pkgutil.html
42.76
KB
-rw-r--r--
platform.html
45.08
KB
-rw-r--r--
plistlib.html
30.06
KB
-rw-r--r--
poplib.html
41.42
KB
-rw-r--r--
posix.html
20.96
KB
-rw-r--r--
pprint.html
55.35
KB
-rw-r--r--
profile.html
84.63
KB
-rw-r--r--
pty.html
23.7
KB
-rw-r--r--
pwd.html
16.84
KB
-rw-r--r--
py_compile.html
29
KB
-rw-r--r--
pyclbr.html
24.06
KB
-rw-r--r--
pydoc.html
19.59
KB
-rw-r--r--
pyexpat.html
104.38
KB
-rw-r--r--
python.html
22.46
KB
-rw-r--r--
queue.html
43.39
KB
-rw-r--r--
quopri.html
18.64
KB
-rw-r--r--
random.html
86.31
KB
-rw-r--r--
re.html
214.24
KB
-rw-r--r--
readline.html
50.19
KB
-rw-r--r--
reprlib.html
30.85
KB
-rw-r--r--
resource.html
48.26
KB
-rw-r--r--
rlcompleter.html
18.06
KB
-rw-r--r--
runpy.html
30.99
KB
-rw-r--r--
sched.html
27.04
KB
-rw-r--r--
secrets.html
30.2
KB
-rw-r--r--
security_warnings.html
16.21
KB
-rw-r--r--
select.html
74.58
KB
-rw-r--r--
selectors.html
41.91
KB
-rw-r--r--
shelve.html
36.54
KB
-rw-r--r--
shlex.html
61.03
KB
-rw-r--r--
shutil.html
100.13
KB
-rw-r--r--
signal.html
95.39
KB
-rw-r--r--
site.html
38.16
KB
-rw-r--r--
smtpd.html
44.09
KB
-rw-r--r--
smtplib.html
81.4
KB
-rw-r--r--
sndhdr.html
16.4
KB
-rw-r--r--
socket.html
256.95
KB
-rw-r--r--
socketserver.html
91.95
KB
-rw-r--r--
spwd.html
16.71
KB
-rw-r--r--
sqlite3.html
225.51
KB
-rw-r--r--
ssl.html
328.83
KB
-rw-r--r--
stat.html
57.79
KB
-rw-r--r--
statistics.html
123.22
KB
-rw-r--r--
stdtypes.html
615.43
KB
-rw-r--r--
string.html
108.03
KB
-rw-r--r--
stringprep.html
24.94
KB
-rw-r--r--
struct.html
70.58
KB
-rw-r--r--
subprocess.html
199.03
KB
-rw-r--r--
sunau.html
39.84
KB
-rw-r--r--
superseded.html
26.21
KB
-rw-r--r--
symtable.html
33.26
KB
-rw-r--r--
sys.html
198.83
KB
-rw-r--r--
sysconfig.html
39.81
KB
-rw-r--r--
syslog.html
27.36
KB
-rw-r--r--
tabnanny.html
16.18
KB
-rw-r--r--
tarfile.html
161.92
KB
-rw-r--r--
telnetlib.html
38.21
KB
-rw-r--r--
tempfile.html
58.39
KB
-rw-r--r--
termios.html
22.86
KB
-rw-r--r--
test.html
222.85
KB
-rw-r--r--
text.html
16.8
KB
-rw-r--r--
textwrap.html
48.83
KB
-rw-r--r--
threading.html
128.33
KB
-rw-r--r--
time.html
107.46
KB
-rw-r--r--
timeit.html
52.63
KB
-rw-r--r--
tk.html
28.08
KB
-rw-r--r--
tkinter.colorchooser.html
14.49
KB
-rw-r--r--
tkinter.dnd.html
17.09
KB
-rw-r--r--
tkinter.font.html
22.21
KB
-rw-r--r--
tkinter.html
106.85
KB
-rw-r--r--
tkinter.messagebox.html
20.09
KB
-rw-r--r--
tkinter.scrolledtext.html
14.52
KB
-rw-r--r--
tkinter.tix.html
59.69
KB
-rw-r--r--
tkinter.ttk.html
138.37
KB
-rw-r--r--
token.html
45.73
KB
-rw-r--r--
tokenize.html
39.86
KB
-rw-r--r--
trace.html
38.85
KB
-rw-r--r--
traceback.html
75.61
KB
-rw-r--r--
tracemalloc.html
122.33
KB
-rw-r--r--
tty.html
14.46
KB
-rw-r--r--
turtle.html
271.71
KB
-rw-r--r--
types.html
64.85
KB
-rw-r--r--
typing.html
315.69
KB
-rw-r--r--
unicodedata.html
27.3
KB
-rw-r--r--
unittest.html
310.01
KB
-rw-r--r--
unittest.mock-examples.html
177.75
KB
-rw-r--r--
unittest.mock.html
363.51
KB
-rw-r--r--
unix.html
13.46
KB
-rw-r--r--
urllib.error.html
18.56
KB
-rw-r--r--
urllib.html
12.92
KB
-rw-r--r--
urllib.parse.html
104.65
KB
-rw-r--r--
urllib.request.html
208.87
KB
-rw-r--r--
urllib.robotparser.html
22.63
KB
-rw-r--r--
uu.html
18.2
KB
-rw-r--r--
uuid.html
42.88
KB
-rw-r--r--
venv.html
90.43
KB
-rw-r--r--
warnings.html
69.13
KB
-rw-r--r--
wave.html
36.12
KB
-rw-r--r--
weakref.html
73.36
KB
-rw-r--r--
webbrowser.html
33.98
KB
-rw-r--r--
windows.html
12.32
KB
-rw-r--r--
winreg.html
89.48
KB
-rw-r--r--
winsound.html
26.3
KB
-rw-r--r--
wsgiref.html
111.52
KB
-rw-r--r--
xdrlib.html
42.07
KB
-rw-r--r--
xml.dom.html
114.66
KB
-rw-r--r--
xml.dom.minidom.html
49.6
KB
-rw-r--r--
xml.dom.pulldom.html
30.06
KB
-rw-r--r--
xml.etree.elementtree.html
186.49
KB
-rw-r--r--
xml.html
22.34
KB
-rw-r--r--
xml.sax.handler.html
55.78
KB
-rw-r--r--
xml.sax.html
31.74
KB
-rw-r--r--
xml.sax.reader.html
56.23
KB
-rw-r--r--
xml.sax.utils.html
22.28
KB
-rw-r--r--
xmlrpc.client.html
79.73
KB
-rw-r--r--
xmlrpc.html
11.9
KB
-rw-r--r--
xmlrpc.server.html
63.56
KB
-rw-r--r--
zipapp.html
52.45
KB
-rw-r--r--
zipfile.html
116.59
KB
-rw-r--r--
zipimport.html
33.76
KB
-rw-r--r--
zlib.html
42.29
KB
-rw-r--r--
zoneinfo.html
57.25
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : pyexpat.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>xml.parsers.expat — Fast XML parsing using Expat — Python 3.10.12 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="../_static/pygments.css" /> <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?2022.1" /> <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 3.10.12 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="Internet Protocols and Support" href="internet.html" /> <link rel="prev" title="xml.sax.xmlreader — Interface for XML parsers" href="xml.sax.reader.html" /> <link rel="canonical" href="file:///usr/share/doc/python3.10/html/library/pyexpat.html" /> <style> @media only screen { table.full-width-table { width: 100%; } } </style> <link rel="shortcut icon" type="image/png" href="../_static/py.svg" /> <script type="text/javascript" src="../_static/copybutton.js"></script> <script type="text/javascript" src="../_static/menu.js"></script> </head> <body> <div class="mobile-nav"> <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation" aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" /> <label for="menuToggler" class="toggler__label"> <span></span> </label> <nav class="nav-content" role="navigation"> <a href="https://www.python.org/" class="nav-logo"> <img src="../_static/py.svg" alt="Logo"/> </a> <div class="version_switcher_placeholder"></div> <form role="search" class="search" action="../search.html" method="get"> <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon"> <path fill-rule="nonzero" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" fill="#444"></path> </svg> <input type="text" name="q" aria-label="Quick search"/> <input type="submit" value="Go"/> </form> </nav> <div class="menu-wrapper"> <nav class="menu" role="navigation" aria-label="main navigation"> <div class="language_switcher_placeholder"></div> <h3><a href="../contents.html">Table of Contents</a></h3> <ul> <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.parsers.expat</span></code> — Fast XML parsing using Expat</a><ul> <li><a class="reference internal" href="#xmlparser-objects">XMLParser Objects</a></li> <li><a class="reference internal" href="#expaterror-exceptions">ExpatError Exceptions</a></li> <li><a class="reference internal" href="#example">Example</a></li> <li><a class="reference internal" href="#module-xml.parsers.expat.model">Content Model Descriptions</a></li> <li><a class="reference internal" href="#module-xml.parsers.expat.errors">Expat error constants</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="xml.sax.reader.html" title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax.xmlreader</span></code> — Interface for XML parsers</a></p> <h4>Next topic</h4> <p class="topless"><a href="internet.html" title="next chapter">Internet Protocols and Support</a></p> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li> <a href="https://github.com/python/cpython/blob/3.10/Doc/library/pyexpat.rst" rel="nofollow">Show Source </a> </li> </ul> </div> </nav> </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" 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="internet.html" title="Internet Protocols and Support" accesskey="N">next</a> |</li> <li class="right" > <a href="xml.sax.reader.html" title="xml.sax.xmlreader — Interface for XML parsers" accesskey="P">previous</a> |</li> <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li class="switchers"> <div class="language_switcher_placeholder"></div> <div class="version_switcher_placeholder"></div> </li> <li> </li> <li id="cpython-language-and-version"> <a href="../index.html">3.10.12 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">Structured Markup Processing Tools</a> »</li> <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.parsers.expat</span></code> — Fast XML parsing using Expat</a></li> <li class="right"> <div class="inline-search" role="search"> <form class="inline-search" action="../search.html" method="get"> <input placeholder="Quick search" aria-label="Quick search" type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> | </li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <section id="module-xml.parsers.expat"> <span id="xml-parsers-expat-fast-xml-parsing-using-expat"></span><h1><a class="reference internal" href="#module-xml.parsers.expat" title="xml.parsers.expat: An interface to the Expat non-validating XML parser."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.parsers.expat</span></code></a> — Fast XML parsing using Expat<a class="headerlink" href="#module-xml.parsers.expat" title="Permalink to this headline">¶</a></h1> <hr class="docutils" /> <div class="admonition warning"> <p class="admonition-title">Warning</p> <p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">pyexpat</span></code> module is not secure against maliciously constructed data. If you need to parse untrusted or unauthenticated data see <a class="reference internal" href="xml.html#xml-vulnerabilities"><span class="std std-ref">XML vulnerabilities</span></a>.</p> </div> <p id="index-0">The <a class="reference internal" href="#module-xml.parsers.expat" title="xml.parsers.expat: An interface to the Expat non-validating XML parser."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.parsers.expat</span></code></a> module is a Python interface to the Expat non-validating XML parser. The module provides a single extension type, <code class="xref py py-class docutils literal notranslate"><span class="pre">xmlparser</span></code>, that represents the current state of an XML parser. After an <code class="xref py py-class docutils literal notranslate"><span class="pre">xmlparser</span></code> object has been created, various attributes of the object can be set to handler functions. When an XML document is then fed to the parser, the handler functions are called for the character data and markup in the XML document.</p> <p id="index-1">This module uses the <code class="xref py py-mod docutils literal notranslate"><span class="pre">pyexpat</span></code> module to provide access to the Expat parser. Direct use of the <code class="xref py py-mod docutils literal notranslate"><span class="pre">pyexpat</span></code> module is deprecated.</p> <p>This module provides one exception and one type object:</p> <dl class="py exception"> <dt class="sig sig-object py" id="xml.parsers.expat.ExpatError"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.</span></span><span class="sig-name descname"><span class="pre">ExpatError</span></span><a class="headerlink" href="#xml.parsers.expat.ExpatError" title="Permalink to this definition">¶</a></dt> <dd><p>The exception raised when Expat reports an error. See section <a class="reference internal" href="#expaterror-objects"><span class="std std-ref">ExpatError Exceptions</span></a> for more information on interpreting Expat errors.</p> </dd></dl> <dl class="py exception"> <dt class="sig sig-object py" id="xml.parsers.expat.error"> <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.</span></span><span class="sig-name descname"><span class="pre">error</span></span><a class="headerlink" href="#xml.parsers.expat.error" title="Permalink to this definition">¶</a></dt> <dd><p>Alias for <a class="reference internal" href="#xml.parsers.expat.ExpatError" title="xml.parsers.expat.ExpatError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ExpatError</span></code></a>.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.XMLParserType"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.</span></span><span class="sig-name descname"><span class="pre">XMLParserType</span></span><a class="headerlink" href="#xml.parsers.expat.XMLParserType" title="Permalink to this definition">¶</a></dt> <dd><p>The type of the return values from the <a class="reference internal" href="#xml.parsers.expat.ParserCreate" title="xml.parsers.expat.ParserCreate"><code class="xref py py-func docutils literal notranslate"><span class="pre">ParserCreate()</span></code></a> function.</p> </dd></dl> <p>The <a class="reference internal" href="#module-xml.parsers.expat" title="xml.parsers.expat: An interface to the Expat non-validating XML parser."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.parsers.expat</span></code></a> module contains two functions:</p> <dl class="py function"> <dt class="sig sig-object py" id="xml.parsers.expat.ErrorString"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.</span></span><span class="sig-name descname"><span class="pre">ErrorString</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">errno</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.ErrorString" title="Permalink to this definition">¶</a></dt> <dd><p>Returns an explanatory string for a given error number <em>errno</em>.</p> </dd></dl> <dl class="py function"> <dt class="sig sig-object py" id="xml.parsers.expat.ParserCreate"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.</span></span><span class="sig-name descname"><span class="pre">ParserCreate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">encoding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">namespace_separator</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.ParserCreate" title="Permalink to this definition">¶</a></dt> <dd><p>Creates and returns a new <code class="xref py py-class docutils literal notranslate"><span class="pre">xmlparser</span></code> object. <em>encoding</em>, if specified, must be a string naming the encoding used by the XML data. Expat doesn’t support as many encodings as Python does, and its repertoire of encodings can’t be extended; it supports UTF-8, UTF-16, ISO-8859-1 (Latin1), and ASCII. If <em>encoding</em> <a class="footnote-reference brackets" href="#id3" id="id1">1</a> is given it will override the implicit or explicit encoding of the document.</p> <p>Expat can optionally do XML namespace processing for you, enabled by providing a value for <em>namespace_separator</em>. The value must be a one-character string; a <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> will be raised if the string has an illegal length (<code class="docutils literal notranslate"><span class="pre">None</span></code> is considered the same as omission). When namespace processing is enabled, element type names and attribute names that belong to a namespace will be expanded. The element name passed to the element handlers <code class="xref py py-attr docutils literal notranslate"><span class="pre">StartElementHandler</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">EndElementHandler</span></code> will be the concatenation of the namespace URI, the namespace separator character, and the local part of the name. If the namespace separator is a zero byte (<code class="docutils literal notranslate"><span class="pre">chr(0)</span></code>) then the namespace URI and the local part will be concatenated without any separator.</p> <p>For example, if <em>namespace_separator</em> is set to a space character (<code class="docutils literal notranslate"><span class="pre">'</span> <span class="pre">'</span></code>) and the following document is parsed:</p> <div class="highlight-xml notranslate"><div class="highlight"><pre><span></span><span class="cp"><?xml version="1.0"?></span> <span class="nt"><root</span> <span class="na">xmlns =</span> <span class="s">"http://default-namespace.org/"</span> <span class="na">xmlns:py =</span> <span class="s">"http://www.python.org/ns/"</span><span class="nt">></span> <span class="nt"><py:elem1</span> <span class="nt">/></span> <span class="nt"><elem2</span> <span class="na">xmlns=</span><span class="s">""</span> <span class="nt">/></span> <span class="nt"></root></span> </pre></div> </div> <p><code class="xref py py-attr docutils literal notranslate"><span class="pre">StartElementHandler</span></code> will receive the following strings for each element:</p> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">default</span><span class="o">-</span><span class="n">namespace</span><span class="o">.</span><span class="n">org</span><span class="o">/</span> <span class="n">root</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">www</span><span class="o">.</span><span class="n">python</span><span class="o">.</span><span class="n">org</span><span class="o">/</span><span class="n">ns</span><span class="o">/</span> <span class="n">elem1</span> <span class="n">elem2</span> </pre></div> </div> <p>Due to limitations in the <code class="docutils literal notranslate"><span class="pre">Expat</span></code> library used by <code class="xref py py-mod docutils literal notranslate"><span class="pre">pyexpat</span></code>, the <code class="xref py py-class docutils literal notranslate"><span class="pre">xmlparser</span></code> instance returned can only be used to parse a single XML document. Call <code class="docutils literal notranslate"><span class="pre">ParserCreate</span></code> for each document to provide unique parser instances.</p> </dd></dl> <div class="admonition seealso"> <p class="admonition-title">See also</p> <dl class="simple"> <dt><a class="reference external" href="http://www.libexpat.org/">The Expat XML Parser</a></dt><dd><p>Home page of the Expat project.</p> </dd> </dl> </div> <section id="xmlparser-objects"> <span id="id2"></span><h2>XMLParser Objects<a class="headerlink" href="#xmlparser-objects" title="Permalink to this headline">¶</a></h2> <p><code class="xref py py-class docutils literal notranslate"><span class="pre">xmlparser</span></code> objects have the following methods:</p> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.Parse"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">Parse</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">isfinal</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.Parse" title="Permalink to this definition">¶</a></dt> <dd><p>Parses the contents of the string <em>data</em>, calling the appropriate handler functions to process the parsed data. <em>isfinal</em> must be true on the final call to this method; it allows the parsing of a single file in fragments, not the submission of multiple files. <em>data</em> can be the empty string at any time.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.ParseFile"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">ParseFile</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.ParseFile" title="Permalink to this definition">¶</a></dt> <dd><p>Parse XML data reading from the object <em>file</em>. <em>file</em> only needs to provide the <code class="docutils literal notranslate"><span class="pre">read(nbytes)</span></code> method, returning the empty string when there’s no more data.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.SetBase"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">SetBase</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">base</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.SetBase" title="Permalink to this definition">¶</a></dt> <dd><p>Sets the base to be used for resolving relative URIs in system identifiers in declarations. Resolving relative identifiers is left to the application: this value will be passed through as the <em>base</em> argument to the <a class="reference internal" href="#xml.parsers.expat.xmlparser.ExternalEntityRefHandler" title="xml.parsers.expat.xmlparser.ExternalEntityRefHandler"><code class="xref py py-func docutils literal notranslate"><span class="pre">ExternalEntityRefHandler()</span></code></a>, <a class="reference internal" href="#xml.parsers.expat.xmlparser.NotationDeclHandler" title="xml.parsers.expat.xmlparser.NotationDeclHandler"><code class="xref py py-func docutils literal notranslate"><span class="pre">NotationDeclHandler()</span></code></a>, and <a class="reference internal" href="#xml.parsers.expat.xmlparser.UnparsedEntityDeclHandler" title="xml.parsers.expat.xmlparser.UnparsedEntityDeclHandler"><code class="xref py py-func docutils literal notranslate"><span class="pre">UnparsedEntityDeclHandler()</span></code></a> functions.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.GetBase"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">GetBase</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.GetBase" title="Permalink to this definition">¶</a></dt> <dd><p>Returns a string containing the base set by a previous call to <a class="reference internal" href="#xml.parsers.expat.xmlparser.SetBase" title="xml.parsers.expat.xmlparser.SetBase"><code class="xref py py-meth docutils literal notranslate"><span class="pre">SetBase()</span></code></a>, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if <a class="reference internal" href="#xml.parsers.expat.xmlparser.SetBase" title="xml.parsers.expat.xmlparser.SetBase"><code class="xref py py-meth docutils literal notranslate"><span class="pre">SetBase()</span></code></a> hasn’t been called.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.GetInputContext"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">GetInputContext</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.GetInputContext" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the input data that generated the current event as a string. The data is in the encoding of the entity which contains the text. When called while an event handler is not active, the return value is <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.parsers.expat.xmlparser.ExternalEntityParserCreate"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">ExternalEntityParserCreate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">context</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">encoding</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.ExternalEntityParserCreate" title="Permalink to this definition">¶</a></dt> <dd><p>Create a “child” parser which can be used to parse an external parsed entity referred to by content parsed by the parent parser. The <em>context</em> parameter should be the string passed to the <a class="reference internal" href="#xml.parsers.expat.xmlparser.ExternalEntityRefHandler" title="xml.parsers.expat.xmlparser.ExternalEntityRefHandler"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ExternalEntityRefHandler()</span></code></a> handler function, described below. The child parser is created with the <a class="reference internal" href="#xml.parsers.expat.xmlparser.ordered_attributes" title="xml.parsers.expat.xmlparser.ordered_attributes"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ordered_attributes</span></code></a> and <a class="reference internal" href="#xml.parsers.expat.xmlparser.specified_attributes" title="xml.parsers.expat.xmlparser.specified_attributes"><code class="xref py py-attr docutils literal notranslate"><span class="pre">specified_attributes</span></code></a> set to the values of this parser.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.SetParamEntityParsing"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">SetParamEntityParsing</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">flag</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.SetParamEntityParsing" title="Permalink to this definition">¶</a></dt> <dd><p>Control parsing of parameter entities (including the external DTD subset). Possible <em>flag</em> values are <code class="xref py py-const docutils literal notranslate"><span class="pre">XML_PARAM_ENTITY_PARSING_NEVER</span></code>, <code class="xref py py-const docutils literal notranslate"><span class="pre">XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE</span></code> and <code class="xref py py-const docutils literal notranslate"><span class="pre">XML_PARAM_ENTITY_PARSING_ALWAYS</span></code>. Return true if setting the flag was successful.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.UseForeignDTD"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">UseForeignDTD</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">flag</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.UseForeignDTD" title="Permalink to this definition">¶</a></dt> <dd><p>Calling this with a true value for <em>flag</em> (the default) will cause Expat to call the <a class="reference internal" href="#xml.parsers.expat.xmlparser.ExternalEntityRefHandler" title="xml.parsers.expat.xmlparser.ExternalEntityRefHandler"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ExternalEntityRefHandler</span></code></a> with <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a> for all arguments to allow an alternate DTD to be loaded. If the document does not contain a document type declaration, the <a class="reference internal" href="#xml.parsers.expat.xmlparser.ExternalEntityRefHandler" title="xml.parsers.expat.xmlparser.ExternalEntityRefHandler"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ExternalEntityRefHandler</span></code></a> will still be called, but the <a class="reference internal" href="#xml.parsers.expat.xmlparser.StartDoctypeDeclHandler" title="xml.parsers.expat.xmlparser.StartDoctypeDeclHandler"><code class="xref py py-attr docutils literal notranslate"><span class="pre">StartDoctypeDeclHandler</span></code></a> and <a class="reference internal" href="#xml.parsers.expat.xmlparser.EndDoctypeDeclHandler" title="xml.parsers.expat.xmlparser.EndDoctypeDeclHandler"><code class="xref py py-attr docutils literal notranslate"><span class="pre">EndDoctypeDeclHandler</span></code></a> will not be called.</p> <p>Passing a false value for <em>flag</em> will cancel a previous call that passed a true value, but otherwise has no effect.</p> <p>This method can only be called before the <a class="reference internal" href="#xml.parsers.expat.xmlparser.Parse" title="xml.parsers.expat.xmlparser.Parse"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Parse()</span></code></a> or <a class="reference internal" href="#xml.parsers.expat.xmlparser.ParseFile" title="xml.parsers.expat.xmlparser.ParseFile"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ParseFile()</span></code></a> methods are called; calling it after either of those have been called causes <a class="reference internal" href="#xml.parsers.expat.ExpatError" title="xml.parsers.expat.ExpatError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ExpatError</span></code></a> to be raised with 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 set to <code class="docutils literal notranslate"><span class="pre">errors.codes[errors.XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING]</span></code>.</p> </dd></dl> <p><code class="xref py py-class docutils literal notranslate"><span class="pre">xmlparser</span></code> objects have the following attributes:</p> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.buffer_size"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">buffer_size</span></span><a class="headerlink" href="#xml.parsers.expat.xmlparser.buffer_size" title="Permalink to this definition">¶</a></dt> <dd><p>The size of the buffer used when <a class="reference internal" href="#xml.parsers.expat.xmlparser.buffer_text" title="xml.parsers.expat.xmlparser.buffer_text"><code class="xref py py-attr docutils literal notranslate"><span class="pre">buffer_text</span></code></a> is true. A new buffer size can be set by assigning a new integer value to this attribute. When the size is changed, the buffer will be flushed.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.buffer_text"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">buffer_text</span></span><a class="headerlink" href="#xml.parsers.expat.xmlparser.buffer_text" title="Permalink to this definition">¶</a></dt> <dd><p>Setting this to true causes the <code class="xref py py-class docutils literal notranslate"><span class="pre">xmlparser</span></code> object to buffer textual content returned by Expat to avoid multiple calls to the <a class="reference internal" href="#xml.parsers.expat.xmlparser.CharacterDataHandler" title="xml.parsers.expat.xmlparser.CharacterDataHandler"><code class="xref py py-meth docutils literal notranslate"><span class="pre">CharacterDataHandler()</span></code></a> callback whenever possible. This can improve performance substantially since Expat normally breaks character data into chunks at every line ending. This attribute is false by default, and may be changed at any time.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.buffer_used"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">buffer_used</span></span><a class="headerlink" href="#xml.parsers.expat.xmlparser.buffer_used" title="Permalink to this definition">¶</a></dt> <dd><p>If <a class="reference internal" href="#xml.parsers.expat.xmlparser.buffer_text" title="xml.parsers.expat.xmlparser.buffer_text"><code class="xref py py-attr docutils literal notranslate"><span class="pre">buffer_text</span></code></a> is enabled, the number of bytes stored in the buffer. These bytes represent UTF-8 encoded text. This attribute has no meaningful interpretation when <a class="reference internal" href="#xml.parsers.expat.xmlparser.buffer_text" title="xml.parsers.expat.xmlparser.buffer_text"><code class="xref py py-attr docutils literal notranslate"><span class="pre">buffer_text</span></code></a> is false.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.ordered_attributes"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">ordered_attributes</span></span><a class="headerlink" href="#xml.parsers.expat.xmlparser.ordered_attributes" title="Permalink to this definition">¶</a></dt> <dd><p>Setting this attribute to a non-zero integer causes the attributes to be reported as a list rather than a dictionary. The attributes are presented in the order found in the document text. For each attribute, two list entries are presented: the attribute name and the attribute value. (Older versions of this module also used this format.) By default, this attribute is false; it may be changed at any time.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.specified_attributes"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">specified_attributes</span></span><a class="headerlink" href="#xml.parsers.expat.xmlparser.specified_attributes" title="Permalink to this definition">¶</a></dt> <dd><p>If set to a non-zero integer, the parser will report only those attributes which were specified in the document instance and not those which were derived from attribute declarations. Applications which set this need to be especially careful to use what additional information is available from the declarations as needed to comply with the standards for the behavior of XML processors. By default, this attribute is false; it may be changed at any time.</p> </dd></dl> <p>The following attributes contain values relating to the most recent error encountered by an <code class="xref py py-class docutils literal notranslate"><span class="pre">xmlparser</span></code> object, and will only have correct values once a call to <code class="xref py py-meth docutils literal notranslate"><span class="pre">Parse()</span></code> or <code class="xref py py-meth docutils literal notranslate"><span class="pre">ParseFile()</span></code> has raised an <a class="reference internal" href="#xml.parsers.expat.ExpatError" title="xml.parsers.expat.ExpatError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">xml.parsers.expat.ExpatError</span></code></a> exception.</p> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.ErrorByteIndex"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">ErrorByteIndex</span></span><a class="headerlink" href="#xml.parsers.expat.xmlparser.ErrorByteIndex" title="Permalink to this definition">¶</a></dt> <dd><p>Byte index at which an error occurred.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.ErrorCode"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">ErrorCode</span></span><a class="headerlink" href="#xml.parsers.expat.xmlparser.ErrorCode" title="Permalink to this definition">¶</a></dt> <dd><p>Numeric code specifying the problem. This value can be passed to the <a class="reference internal" href="#xml.parsers.expat.ErrorString" title="xml.parsers.expat.ErrorString"><code class="xref py py-func docutils literal notranslate"><span class="pre">ErrorString()</span></code></a> function, or compared to one of the constants defined in the <code class="docutils literal notranslate"><span class="pre">errors</span></code> object.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.ErrorColumnNumber"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">ErrorColumnNumber</span></span><a class="headerlink" href="#xml.parsers.expat.xmlparser.ErrorColumnNumber" title="Permalink to this definition">¶</a></dt> <dd><p>Column number at which an error occurred.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.ErrorLineNumber"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">ErrorLineNumber</span></span><a class="headerlink" href="#xml.parsers.expat.xmlparser.ErrorLineNumber" title="Permalink to this definition">¶</a></dt> <dd><p>Line number at which an error occurred.</p> </dd></dl> <p>The following attributes contain values relating to the current parse location in an <code class="xref py py-class docutils literal notranslate"><span class="pre">xmlparser</span></code> object. During a callback reporting a parse event they indicate the location of the first of the sequence of characters that generated the event. When called outside of a callback, the position indicated will be just past the last parse event (regardless of whether there was an associated callback).</p> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.CurrentByteIndex"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">CurrentByteIndex</span></span><a class="headerlink" href="#xml.parsers.expat.xmlparser.CurrentByteIndex" title="Permalink to this definition">¶</a></dt> <dd><p>Current byte index in the parser input.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.CurrentColumnNumber"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">CurrentColumnNumber</span></span><a class="headerlink" href="#xml.parsers.expat.xmlparser.CurrentColumnNumber" title="Permalink to this definition">¶</a></dt> <dd><p>Current column number in the parser input.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.CurrentLineNumber"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">CurrentLineNumber</span></span><a class="headerlink" href="#xml.parsers.expat.xmlparser.CurrentLineNumber" title="Permalink to this definition">¶</a></dt> <dd><p>Current line number in the parser input.</p> </dd></dl> <p>Here is the list of handlers that can be set. To set a handler on an <code class="xref py py-class docutils literal notranslate"><span class="pre">xmlparser</span></code> object <em>o</em>, use <code class="docutils literal notranslate"><span class="pre">o.handlername</span> <span class="pre">=</span> <span class="pre">func</span></code>. <em>handlername</em> must be taken from the following list, and <em>func</em> must be a callable object accepting the correct number of arguments. The arguments are all strings, unless otherwise stated.</p> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.XmlDeclHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">XmlDeclHandler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">version</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">encoding</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">standalone</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.XmlDeclHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called when the XML declaration is parsed. The XML declaration is the (optional) declaration of the applicable version of the XML recommendation, the encoding of the document text, and an optional “standalone” declaration. <em>version</em> and <em>encoding</em> will be strings, and <em>standalone</em> will be <code class="docutils literal notranslate"><span class="pre">1</span></code> if the document is declared standalone, <code class="docutils literal notranslate"><span class="pre">0</span></code> if it is declared not to be standalone, or <code class="docutils literal notranslate"><span class="pre">-1</span></code> if the standalone clause was omitted. This is only available with Expat version 1.95.0 or newer.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.StartDoctypeDeclHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">StartDoctypeDeclHandler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">doctypeName</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">systemId</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">has_internal_subset</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.StartDoctypeDeclHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called when Expat begins parsing the document type declaration (<code class="docutils literal notranslate"><span class="pre"><!DOCTYPE</span> <span class="pre">...</span></code>). The <em>doctypeName</em> is provided exactly as presented. The <em>systemId</em> and <em>publicId</em> parameters give the system and public identifiers if specified, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if omitted. <em>has_internal_subset</em> will be true if the document contains and internal document declaration subset. This requires Expat version 1.2 or newer.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.EndDoctypeDeclHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">EndDoctypeDeclHandler</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.EndDoctypeDeclHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called when Expat is done parsing the document type declaration. This requires Expat version 1.2 or newer.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.ElementDeclHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">ElementDeclHandler</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">model</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.ElementDeclHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called once for each element type declaration. <em>name</em> is the name of the element type, and <em>model</em> is a representation of the content model.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.AttlistDeclHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">AttlistDeclHandler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">elname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">required</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.AttlistDeclHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called for each declared attribute for an element type. If an attribute list declaration declares three attributes, this handler is called three times, once for each attribute. <em>elname</em> is the name of the element to which the declaration applies and <em>attname</em> is the name of the attribute declared. The attribute type is a string passed as <em>type</em>; the possible values are <code class="docutils literal notranslate"><span class="pre">'CDATA'</span></code>, <code class="docutils literal notranslate"><span class="pre">'ID'</span></code>, <code class="docutils literal notranslate"><span class="pre">'IDREF'</span></code>, … <em>default</em> gives the default value for the attribute used when the attribute is not specified by the document instance, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if there is no default value (<code class="docutils literal notranslate"><span class="pre">#IMPLIED</span></code> values). If the attribute is required to be given in the document instance, <em>required</em> will be true. This requires Expat version 1.95.0 or newer.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.StartElementHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">StartElementHandler</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">attributes</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.StartElementHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called for the start of every element. <em>name</em> is a string containing the element name, and <em>attributes</em> is the element attributes. If <a class="reference internal" href="#xml.parsers.expat.xmlparser.ordered_attributes" title="xml.parsers.expat.xmlparser.ordered_attributes"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ordered_attributes</span></code></a> is true, this is a list (see <a class="reference internal" href="#xml.parsers.expat.xmlparser.ordered_attributes" title="xml.parsers.expat.xmlparser.ordered_attributes"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ordered_attributes</span></code></a> for a full description). Otherwise it’s a dictionary mapping names to values.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.EndElementHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">EndElementHandler</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.parsers.expat.xmlparser.EndElementHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called for the end of every element.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.ProcessingInstructionHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">ProcessingInstructionHandler</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.parsers.expat.xmlparser.ProcessingInstructionHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called for every processing instruction.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.CharacterDataHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">CharacterDataHandler</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.parsers.expat.xmlparser.CharacterDataHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called for character data. This will be called for normal character data, CDATA marked content, and ignorable whitespace. Applications which must distinguish these cases can use the <a class="reference internal" href="#xml.parsers.expat.xmlparser.StartCdataSectionHandler" title="xml.parsers.expat.xmlparser.StartCdataSectionHandler"><code class="xref py py-attr docutils literal notranslate"><span class="pre">StartCdataSectionHandler</span></code></a>, <a class="reference internal" href="#xml.parsers.expat.xmlparser.EndCdataSectionHandler" title="xml.parsers.expat.xmlparser.EndCdataSectionHandler"><code class="xref py py-attr docutils literal notranslate"><span class="pre">EndCdataSectionHandler</span></code></a>, and <a class="reference internal" href="#xml.parsers.expat.xmlparser.ElementDeclHandler" title="xml.parsers.expat.xmlparser.ElementDeclHandler"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ElementDeclHandler</span></code></a> callbacks to collect the required information.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.UnparsedEntityDeclHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">UnparsedEntityDeclHandler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">entityName</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">base</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">systemId</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">notationName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.UnparsedEntityDeclHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called for unparsed (NDATA) entity declarations. This is only present for version 1.2 of the Expat library; for more recent versions, use <a class="reference internal" href="#xml.parsers.expat.xmlparser.EntityDeclHandler" title="xml.parsers.expat.xmlparser.EntityDeclHandler"><code class="xref py py-attr docutils literal notranslate"><span class="pre">EntityDeclHandler</span></code></a> instead. (The underlying function in the Expat library has been declared obsolete.)</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.EntityDeclHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">EntityDeclHandler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">entityName</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">is_parameter_entity</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">base</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">systemId</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">notationName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.EntityDeclHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called for all entity declarations. For parameter and internal entities, <em>value</em> will be a string giving the declared contents of the entity; this will be <code class="docutils literal notranslate"><span class="pre">None</span></code> for external entities. The <em>notationName</em> parameter will be <code class="docutils literal notranslate"><span class="pre">None</span></code> for parsed entities, and the name of the notation for unparsed entities. <em>is_parameter_entity</em> will be true if the entity is a parameter entity or false for general entities (most applications only need to be concerned with general entities). This is only available starting with version 1.95.0 of the Expat library.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.NotationDeclHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">NotationDeclHandler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">notationName</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">base</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">systemId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">publicId</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.NotationDeclHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called for notation declarations. <em>notationName</em>, <em>base</em>, and <em>systemId</em>, and <em>publicId</em> are strings if given. If the public identifier is omitted, <em>publicId</em> will be <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.parsers.expat.xmlparser.StartNamespaceDeclHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">StartNamespaceDeclHandler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prefix</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">uri</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.StartNamespaceDeclHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called when an element contains a namespace declaration. Namespace declarations are processed before the <a class="reference internal" href="#xml.parsers.expat.xmlparser.StartElementHandler" title="xml.parsers.expat.xmlparser.StartElementHandler"><code class="xref py py-attr docutils literal notranslate"><span class="pre">StartElementHandler</span></code></a> is called for the element on which declarations are placed.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.EndNamespaceDeclHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">EndNamespaceDeclHandler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prefix</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.EndNamespaceDeclHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called when the closing tag is reached for an element that contained a namespace declaration. This is called once for each namespace declaration on the element in the reverse of the order for which the <a class="reference internal" href="#xml.parsers.expat.xmlparser.StartNamespaceDeclHandler" title="xml.parsers.expat.xmlparser.StartNamespaceDeclHandler"><code class="xref py py-attr docutils literal notranslate"><span class="pre">StartNamespaceDeclHandler</span></code></a> was called to indicate the start of each namespace declaration’s scope. Calls to this handler are made after the corresponding <a class="reference internal" href="#xml.parsers.expat.xmlparser.EndElementHandler" title="xml.parsers.expat.xmlparser.EndElementHandler"><code class="xref py py-attr docutils literal notranslate"><span class="pre">EndElementHandler</span></code></a> for the end of the element.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.CommentHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">CommentHandler</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.parsers.expat.xmlparser.CommentHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called for comments. <em>data</em> is the text of the comment, excluding 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>.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.StartCdataSectionHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">StartCdataSectionHandler</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.StartCdataSectionHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called at the start of a CDATA section. This and <a class="reference internal" href="#xml.parsers.expat.xmlparser.EndCdataSectionHandler" title="xml.parsers.expat.xmlparser.EndCdataSectionHandler"><code class="xref py py-attr docutils literal notranslate"><span class="pre">EndCdataSectionHandler</span></code></a> are needed to be able to identify the syntactical start and end for CDATA sections.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.EndCdataSectionHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">EndCdataSectionHandler</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.EndCdataSectionHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called at the end of a CDATA section.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.DefaultHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">DefaultHandler</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.parsers.expat.xmlparser.DefaultHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called for any characters in the XML document for which no applicable handler has been specified. This means characters that are part of a construct which could be reported, but for which no handler has been supplied.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.DefaultHandlerExpand"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">DefaultHandlerExpand</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.parsers.expat.xmlparser.DefaultHandlerExpand" title="Permalink to this definition">¶</a></dt> <dd><p>This is the same as the <a class="reference internal" href="#xml.parsers.expat.xmlparser.DefaultHandler" title="xml.parsers.expat.xmlparser.DefaultHandler"><code class="xref py py-func docutils literal notranslate"><span class="pre">DefaultHandler()</span></code></a>, but doesn’t inhibit expansion of internal entities. The entity reference will not be passed to the default handler.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.NotStandaloneHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">NotStandaloneHandler</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.NotStandaloneHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called if the XML document hasn’t been declared as being a standalone document. This happens when there is an external subset or a reference to a parameter entity, but the XML declaration does not set standalone to <code class="docutils literal notranslate"><span class="pre">yes</span></code> in an XML declaration. If this handler returns <code class="docutils literal notranslate"><span class="pre">0</span></code>, then the parser will raise an <code class="xref py py-const docutils literal notranslate"><span class="pre">XML_ERROR_NOT_STANDALONE</span></code> error. If this handler is not set, no exception is raised by the parser for this condition.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="xml.parsers.expat.xmlparser.ExternalEntityRefHandler"> <span class="sig-prename descclassname"><span class="pre">xmlparser.</span></span><span class="sig-name descname"><span class="pre">ExternalEntityRefHandler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">context</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">base</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">systemId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">publicId</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.parsers.expat.xmlparser.ExternalEntityRefHandler" title="Permalink to this definition">¶</a></dt> <dd><p>Called for references to external entities. <em>base</em> is the current base, as set by a previous call to <a class="reference internal" href="#xml.parsers.expat.xmlparser.SetBase" title="xml.parsers.expat.xmlparser.SetBase"><code class="xref py py-meth docutils literal notranslate"><span class="pre">SetBase()</span></code></a>. The public and system identifiers, <em>systemId</em> and <em>publicId</em>, are strings if given; if the public identifier is not given, <em>publicId</em> will be <code class="docutils literal notranslate"><span class="pre">None</span></code>. The <em>context</em> value is opaque and should only be used as described below.</p> <p>For external entities to be parsed, this handler must be implemented. It is responsible for creating the sub-parser using <code class="docutils literal notranslate"><span class="pre">ExternalEntityParserCreate(context)</span></code>, initializing it with the appropriate callbacks, and parsing the entity. This handler should return an integer; if it returns <code class="docutils literal notranslate"><span class="pre">0</span></code>, the parser will raise an <code class="xref py py-const docutils literal notranslate"><span class="pre">XML_ERROR_EXTERNAL_ENTITY_HANDLING</span></code> error, otherwise parsing will continue.</p> <p>If this handler is not provided, external entities are reported by the <a class="reference internal" href="#xml.parsers.expat.xmlparser.DefaultHandler" title="xml.parsers.expat.xmlparser.DefaultHandler"><code class="xref py py-attr docutils literal notranslate"><span class="pre">DefaultHandler</span></code></a> callback, if provided.</p> </dd></dl> </section> <section id="expaterror-exceptions"> <span id="expaterror-objects"></span><h2>ExpatError Exceptions<a class="headerlink" href="#expaterror-exceptions" title="Permalink to this headline">¶</a></h2> <p><a class="reference internal" href="#xml.parsers.expat.ExpatError" title="xml.parsers.expat.ExpatError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ExpatError</span></code></a> exceptions have a number of interesting attributes:</p> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.ExpatError.code"> <span class="sig-prename descclassname"><span class="pre">ExpatError.</span></span><span class="sig-name descname"><span class="pre">code</span></span><a class="headerlink" href="#xml.parsers.expat.ExpatError.code" title="Permalink to this definition">¶</a></dt> <dd><p>Expat’s internal error number for the specific error. The <a class="reference internal" href="#xml.parsers.expat.errors.messages" title="xml.parsers.expat.errors.messages"><code class="xref py py-data docutils literal notranslate"><span class="pre">errors.messages</span></code></a> dictionary maps these error numbers to Expat’s error messages. For example:</p> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">xml.parsers.expat</span> <span class="kn">import</span> <span class="n">ParserCreate</span><span class="p">,</span> <span class="n">ExpatError</span><span class="p">,</span> <span class="n">errors</span> <span class="n">p</span> <span class="o">=</span> <span class="n">ParserCreate</span><span class="p">()</span> <span class="k">try</span><span class="p">:</span> <span class="n">p</span><span class="o">.</span><span class="n">Parse</span><span class="p">(</span><span class="n">some_xml_document</span><span class="p">)</span> <span class="k">except</span> <span class="n">ExpatError</span> <span class="k">as</span> <span class="n">err</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s2">"Error:"</span><span class="p">,</span> <span class="n">errors</span><span class="o">.</span><span class="n">messages</span><span class="p">[</span><span class="n">err</span><span class="o">.</span><span class="n">code</span><span class="p">])</span> </pre></div> </div> <p>The <a class="reference internal" href="#module-xml.parsers.expat.errors" title="xml.parsers.expat.errors"><code class="xref py py-mod docutils literal notranslate"><span class="pre">errors</span></code></a> module also provides error message constants and a dictionary <a class="reference internal" href="#xml.parsers.expat.errors.codes" title="xml.parsers.expat.errors.codes"><code class="xref py py-data docutils literal notranslate"><span class="pre">codes</span></code></a> mapping these messages back to the error codes, see below.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.ExpatError.lineno"> <span class="sig-prename descclassname"><span class="pre">ExpatError.</span></span><span class="sig-name descname"><span class="pre">lineno</span></span><a class="headerlink" href="#xml.parsers.expat.ExpatError.lineno" title="Permalink to this definition">¶</a></dt> <dd><p>Line number on which the error was detected. The first line is numbered <code class="docutils literal notranslate"><span class="pre">1</span></code>.</p> </dd></dl> <dl class="py attribute"> <dt class="sig sig-object py" id="xml.parsers.expat.ExpatError.offset"> <span class="sig-prename descclassname"><span class="pre">ExpatError.</span></span><span class="sig-name descname"><span class="pre">offset</span></span><a class="headerlink" href="#xml.parsers.expat.ExpatError.offset" title="Permalink to this definition">¶</a></dt> <dd><p>Character offset into the line where the error occurred. The first column is numbered <code class="docutils literal notranslate"><span class="pre">0</span></code>.</p> </dd></dl> </section> <section id="example"> <span id="expat-example"></span><h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2> <p>The following program defines three handlers that just print out their arguments.</p> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">xml.parsers.expat</span> <span class="c1"># 3 handler functions</span> <span class="k">def</span> <span class="nf">start_element</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">attrs</span><span class="p">):</span> <span class="nb">print</span><span class="p">(</span><span class="s1">'Start element:'</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">attrs</span><span class="p">)</span> <span class="k">def</span> <span class="nf">end_element</span><span class="p">(</span><span class="n">name</span><span class="p">):</span> <span class="nb">print</span><span class="p">(</span><span class="s1">'End element:'</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span> <span class="k">def</span> <span class="nf">char_data</span><span class="p">(</span><span class="n">data</span><span class="p">):</span> <span class="nb">print</span><span class="p">(</span><span class="s1">'Character data:'</span><span class="p">,</span> <span class="nb">repr</span><span class="p">(</span><span class="n">data</span><span class="p">))</span> <span class="n">p</span> <span class="o">=</span> <span class="n">xml</span><span class="o">.</span><span class="n">parsers</span><span class="o">.</span><span class="n">expat</span><span class="o">.</span><span class="n">ParserCreate</span><span class="p">()</span> <span class="n">p</span><span class="o">.</span><span class="n">StartElementHandler</span> <span class="o">=</span> <span class="n">start_element</span> <span class="n">p</span><span class="o">.</span><span class="n">EndElementHandler</span> <span class="o">=</span> <span class="n">end_element</span> <span class="n">p</span><span class="o">.</span><span class="n">CharacterDataHandler</span> <span class="o">=</span> <span class="n">char_data</span> <span class="n">p</span><span class="o">.</span><span class="n">Parse</span><span class="p">(</span><span class="s2">"""<?xml version="1.0"?></span> <span class="s2"><parent id="top"><child1 name="paul">Text goes here</child1></span> <span class="s2"><child2 name="fred">More text</child2></span> <span class="s2"></parent>"""</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </pre></div> </div> <p>The output from this program is:</p> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">Start</span> <span class="n">element</span><span class="p">:</span> <span class="n">parent</span> <span class="p">{</span><span class="s1">'id'</span><span class="p">:</span> <span class="s1">'top'</span><span class="p">}</span> <span class="n">Start</span> <span class="n">element</span><span class="p">:</span> <span class="n">child1</span> <span class="p">{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'paul'</span><span class="p">}</span> <span class="n">Character</span> <span class="n">data</span><span class="p">:</span> <span class="s1">'Text goes here'</span> <span class="n">End</span> <span class="n">element</span><span class="p">:</span> <span class="n">child1</span> <span class="n">Character</span> <span class="n">data</span><span class="p">:</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">'</span> <span class="n">Start</span> <span class="n">element</span><span class="p">:</span> <span class="n">child2</span> <span class="p">{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'fred'</span><span class="p">}</span> <span class="n">Character</span> <span class="n">data</span><span class="p">:</span> <span class="s1">'More text'</span> <span class="n">End</span> <span class="n">element</span><span class="p">:</span> <span class="n">child2</span> <span class="n">Character</span> <span class="n">data</span><span class="p">:</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">'</span> <span class="n">End</span> <span class="n">element</span><span class="p">:</span> <span class="n">parent</span> </pre></div> </div> </section> <section id="module-xml.parsers.expat.model"> <span id="content-model-descriptions"></span><span id="expat-content-models"></span><h2>Content Model Descriptions<a class="headerlink" href="#module-xml.parsers.expat.model" title="Permalink to this headline">¶</a></h2> <p>Content models are described using nested tuples. Each tuple contains four values: the type, the quantifier, the name, and a tuple of children. Children are simply additional content model descriptions.</p> <p>The values of the first two fields are constants defined in the <a class="reference internal" href="#module-xml.parsers.expat.model" title="xml.parsers.expat.model"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.parsers.expat.model</span></code></a> module. These constants can be collected in two groups: the model type group and the quantifier group.</p> <p>The constants in the model type group are:</p> <dl class="py data"> <dt class="sig sig-object py"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.model.</span></span><span class="sig-name descname"><span class="pre">XML_CTYPE_ANY</span></span></dt> <dd><p>The element named by the model name was declared to have a content model of <code class="docutils literal notranslate"><span class="pre">ANY</span></code>.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.model.</span></span><span class="sig-name descname"><span class="pre">XML_CTYPE_CHOICE</span></span></dt> <dd><p>The named element allows a choice from a number of options; this is used for content models such as <code class="docutils literal notranslate"><span class="pre">(A</span> <span class="pre">|</span> <span class="pre">B</span> <span class="pre">|</span> <span class="pre">C)</span></code>.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.model.</span></span><span class="sig-name descname"><span class="pre">XML_CTYPE_EMPTY</span></span></dt> <dd><p>Elements which are declared to be <code class="docutils literal notranslate"><span class="pre">EMPTY</span></code> have this model type.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.model.</span></span><span class="sig-name descname"><span class="pre">XML_CTYPE_MIXED</span></span></dt> <dd></dd></dl> <dl class="py data"> <dt class="sig sig-object py"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.model.</span></span><span class="sig-name descname"><span class="pre">XML_CTYPE_NAME</span></span></dt> <dd></dd></dl> <dl class="py data"> <dt class="sig sig-object py"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.model.</span></span><span class="sig-name descname"><span class="pre">XML_CTYPE_SEQ</span></span></dt> <dd><p>Models which represent a series of models which follow one after the other are indicated with this model type. This is used for models such as <code class="docutils literal notranslate"><span class="pre">(A,</span> <span class="pre">B,</span> <span class="pre">C)</span></code>.</p> </dd></dl> <p>The constants in the quantifier group are:</p> <dl class="py data"> <dt class="sig sig-object py"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.model.</span></span><span class="sig-name descname"><span class="pre">XML_CQUANT_NONE</span></span></dt> <dd><p>No modifier is given, so it can appear exactly once, as for <code class="docutils literal notranslate"><span class="pre">A</span></code>.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.model.</span></span><span class="sig-name descname"><span class="pre">XML_CQUANT_OPT</span></span></dt> <dd><p>The model is optional: it can appear once or not at all, as for <code class="docutils literal notranslate"><span class="pre">A?</span></code>.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.model.</span></span><span class="sig-name descname"><span class="pre">XML_CQUANT_PLUS</span></span></dt> <dd><p>The model must occur one or more times (like <code class="docutils literal notranslate"><span class="pre">A+</span></code>).</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.model.</span></span><span class="sig-name descname"><span class="pre">XML_CQUANT_REP</span></span></dt> <dd><p>The model must occur zero or more times, as for <code class="docutils literal notranslate"><span class="pre">A*</span></code>.</p> </dd></dl> </section> <section id="module-xml.parsers.expat.errors"> <span id="expat-error-constants"></span><span id="expat-errors"></span><h2>Expat error constants<a class="headerlink" href="#module-xml.parsers.expat.errors" title="Permalink to this headline">¶</a></h2> <p>The following constants are provided in the <a class="reference internal" href="#module-xml.parsers.expat.errors" title="xml.parsers.expat.errors"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.parsers.expat.errors</span></code></a> module. These constants are useful in interpreting some of the attributes of the <code class="xref py py-exc docutils literal notranslate"><span class="pre">ExpatError</span></code> exception objects raised when an error has occurred. Since for backwards compatibility reasons, the constants’ value is the error <em>message</em> and not the numeric error <em>code</em>, you do this by comparing its <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 with <code class="samp docutils literal notranslate"><span class="pre">errors.codes[errors.XML_ERROR_</span><em><span class="pre">CONSTANT_NAME</span></em><span class="pre">]</span></code>.</p> <p>The <code class="docutils literal notranslate"><span class="pre">errors</span></code> module has the following attributes:</p> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.codes"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">codes</span></span><a class="headerlink" href="#xml.parsers.expat.errors.codes" title="Permalink to this definition">¶</a></dt> <dd><p>A dictionary mapping string descriptions to their error codes.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.2.</span></p> </div> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.messages"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">messages</span></span><a class="headerlink" href="#xml.parsers.expat.errors.messages" title="Permalink to this definition">¶</a></dt> <dd><p>A dictionary mapping numeric error codes to their string descriptions.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.2.</span></p> </div> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_ASYNC_ENTITY"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_ASYNC_ENTITY</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_ASYNC_ENTITY" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF" title="Permalink to this definition">¶</a></dt> <dd><p>An entity reference in an attribute value referred to an external entity instead of an internal entity.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_BAD_CHAR_REF"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_BAD_CHAR_REF</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_BAD_CHAR_REF" title="Permalink to this definition">¶</a></dt> <dd><p>A character reference referred to a character which is illegal in XML (for example, character <code class="docutils literal notranslate"><span class="pre">0</span></code>, or ‘<code class="docutils literal notranslate"><span class="pre">&#0;</span></code>’).</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_BINARY_ENTITY_REF"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_BINARY_ENTITY_REF</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_BINARY_ENTITY_REF" title="Permalink to this definition">¶</a></dt> <dd><p>An entity reference referred to an entity which was declared with a notation, so cannot be parsed.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_DUPLICATE_ATTRIBUTE"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_DUPLICATE_ATTRIBUTE</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_DUPLICATE_ATTRIBUTE" title="Permalink to this definition">¶</a></dt> <dd><p>An attribute was used more than once in a start tag.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_INCORRECT_ENCODING"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_INCORRECT_ENCODING</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_INCORRECT_ENCODING" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_INVALID_TOKEN"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_INVALID_TOKEN</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_INVALID_TOKEN" title="Permalink to this definition">¶</a></dt> <dd><p>Raised when an input byte could not properly be assigned to a character; for example, a NUL byte (value <code class="docutils literal notranslate"><span class="pre">0</span></code>) in a UTF-8 input stream.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_JUNK_AFTER_DOC_ELEMENT"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_JUNK_AFTER_DOC_ELEMENT</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_JUNK_AFTER_DOC_ELEMENT" title="Permalink to this definition">¶</a></dt> <dd><p>Something other than whitespace occurred after the document element.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_MISPLACED_XML_PI"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_MISPLACED_XML_PI</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_MISPLACED_XML_PI" title="Permalink to this definition">¶</a></dt> <dd><p>An XML declaration was found somewhere other than the start of the input data.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_NO_ELEMENTS"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_NO_ELEMENTS</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_NO_ELEMENTS" title="Permalink to this definition">¶</a></dt> <dd><p>The document contains no elements (XML requires all documents to contain exactly one top-level element)..</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_NO_MEMORY"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_NO_MEMORY</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_NO_MEMORY" title="Permalink to this definition">¶</a></dt> <dd><p>Expat was not able to allocate memory internally.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_PARAM_ENTITY_REF"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_PARAM_ENTITY_REF</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_PARAM_ENTITY_REF" title="Permalink to this definition">¶</a></dt> <dd><p>A parameter entity reference was found where it was not allowed.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_PARTIAL_CHAR"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_PARTIAL_CHAR</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_PARTIAL_CHAR" title="Permalink to this definition">¶</a></dt> <dd><p>An incomplete character was found in the input.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_RECURSIVE_ENTITY_REF"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_RECURSIVE_ENTITY_REF</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_RECURSIVE_ENTITY_REF" title="Permalink to this definition">¶</a></dt> <dd><p>An entity reference contained another reference to the same entity; possibly via a different name, and possibly indirectly.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_SYNTAX"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_SYNTAX</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_SYNTAX" title="Permalink to this definition">¶</a></dt> <dd><p>Some unspecified syntax error was encountered.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_TAG_MISMATCH"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_TAG_MISMATCH</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_TAG_MISMATCH" title="Permalink to this definition">¶</a></dt> <dd><p>An end tag did not match the innermost open start tag.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_UNCLOSED_TOKEN"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_UNCLOSED_TOKEN</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_UNCLOSED_TOKEN" title="Permalink to this definition">¶</a></dt> <dd><p>Some token (such as a start tag) was not closed before the end of the stream or the next token was encountered.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_UNDEFINED_ENTITY"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_UNDEFINED_ENTITY</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_UNDEFINED_ENTITY" title="Permalink to this definition">¶</a></dt> <dd><p>A reference was made to an entity which was not defined.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_UNKNOWN_ENCODING"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_UNKNOWN_ENCODING</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_UNKNOWN_ENCODING" title="Permalink to this definition">¶</a></dt> <dd><p>The document encoding is not supported by Expat.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_UNCLOSED_CDATA_SECTION"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_UNCLOSED_CDATA_SECTION</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_UNCLOSED_CDATA_SECTION" title="Permalink to this definition">¶</a></dt> <dd><p>A CDATA marked section was not closed.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_EXTERNAL_ENTITY_HANDLING"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_EXTERNAL_ENTITY_HANDLING</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_EXTERNAL_ENTITY_HANDLING" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_NOT_STANDALONE"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_NOT_STANDALONE</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_NOT_STANDALONE" title="Permalink to this definition">¶</a></dt> <dd><p>The parser determined that the document was not “standalone” though it declared itself to be in the XML declaration, and the <code class="xref py py-attr docutils literal notranslate"><span class="pre">NotStandaloneHandler</span></code> was set and returned <code class="docutils literal notranslate"><span class="pre">0</span></code>.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_UNEXPECTED_STATE"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_UNEXPECTED_STATE</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_UNEXPECTED_STATE" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_ENTITY_DECLARED_IN_PE"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_ENTITY_DECLARED_IN_PE</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_ENTITY_DECLARED_IN_PE" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_FEATURE_REQUIRES_XML_DTD"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_FEATURE_REQUIRES_XML_DTD</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_FEATURE_REQUIRES_XML_DTD" title="Permalink to this definition">¶</a></dt> <dd><p>An operation was requested that requires DTD support to be compiled in, but Expat was configured without DTD support. This should never be reported by a standard build of the <a class="reference internal" href="#module-xml.parsers.expat" title="xml.parsers.expat: An interface to the Expat non-validating XML parser."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.parsers.expat</span></code></a> module.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING" title="Permalink to this definition">¶</a></dt> <dd><p>A behavioral change was requested after parsing started that can only be changed before parsing has started. This is (currently) only raised by <code class="xref py py-meth docutils literal notranslate"><span class="pre">UseForeignDTD()</span></code>.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_UNBOUND_PREFIX"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_UNBOUND_PREFIX</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_UNBOUND_PREFIX" title="Permalink to this definition">¶</a></dt> <dd><p>An undeclared prefix was found when namespace processing was enabled.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_UNDECLARING_PREFIX"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_UNDECLARING_PREFIX</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_UNDECLARING_PREFIX" title="Permalink to this definition">¶</a></dt> <dd><p>The document attempted to remove the namespace declaration associated with a prefix.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_INCOMPLETE_PE"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_INCOMPLETE_PE</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_INCOMPLETE_PE" title="Permalink to this definition">¶</a></dt> <dd><p>A parameter entity contained incomplete markup.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_XML_DECL"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_XML_DECL</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_XML_DECL" title="Permalink to this definition">¶</a></dt> <dd><p>The document contained no document element at all.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_TEXT_DECL"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_TEXT_DECL</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_TEXT_DECL" title="Permalink to this definition">¶</a></dt> <dd><p>There was an error parsing a text declaration in an external entity.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_PUBLICID"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_PUBLICID</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_PUBLICID" title="Permalink to this definition">¶</a></dt> <dd><p>Characters were found in the public id that are not allowed.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_SUSPENDED"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_SUSPENDED</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_SUSPENDED" title="Permalink to this definition">¶</a></dt> <dd><p>The requested operation was made on a suspended parser, but isn’t allowed. This includes attempts to provide additional input or to stop the parser.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_NOT_SUSPENDED"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_NOT_SUSPENDED</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_NOT_SUSPENDED" title="Permalink to this definition">¶</a></dt> <dd><p>An attempt to resume the parser was made when the parser had not been suspended.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_ABORTED"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_ABORTED</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_ABORTED" title="Permalink to this definition">¶</a></dt> <dd><p>This should not be reported to Python applications.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_FINISHED"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_FINISHED</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_FINISHED" title="Permalink to this definition">¶</a></dt> <dd><p>The requested operation was made on a parser which was finished parsing input, but isn’t allowed. This includes attempts to provide additional input or to stop the parser.</p> </dd></dl> <dl class="py data"> <dt class="sig sig-object py" id="xml.parsers.expat.errors.XML_ERROR_SUSPEND_PE"> <span class="sig-prename descclassname"><span class="pre">xml.parsers.expat.errors.</span></span><span class="sig-name descname"><span class="pre">XML_ERROR_SUSPEND_PE</span></span><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_SUSPEND_PE" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p class="rubric">Footnotes</p> <dl class="footnote brackets"> <dt class="label" id="id3"><span class="brackets"><a class="fn-backref" href="#id1">1</a></span></dt> <dd><p>The encoding string included in XML output should conform to the appropriate standards. For example, “UTF-8” is valid, but “UTF8” is not. See <a class="reference external" href="https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl">https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl</a> and <a class="reference external" href="https://www.iana.org/assignments/character-sets/character-sets.xhtml">https://www.iana.org/assignments/character-sets/character-sets.xhtml</a>.</p> </dd> </dl> </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="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.parsers.expat</span></code> — Fast XML parsing using Expat</a><ul> <li><a class="reference internal" href="#xmlparser-objects">XMLParser Objects</a></li> <li><a class="reference internal" href="#expaterror-exceptions">ExpatError Exceptions</a></li> <li><a class="reference internal" href="#example">Example</a></li> <li><a class="reference internal" href="#module-xml.parsers.expat.model">Content Model Descriptions</a></li> <li><a class="reference internal" href="#module-xml.parsers.expat.errors">Expat error constants</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="xml.sax.reader.html" title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax.xmlreader</span></code> — Interface for XML parsers</a></p> <h4>Next topic</h4> <p class="topless"><a href="internet.html" title="next chapter">Internet Protocols and Support</a></p> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li> <a href="https://github.com/python/cpython/blob/3.10/Doc/library/pyexpat.rst" rel="nofollow">Show Source </a> </li> </ul> </div> </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="internet.html" title="Internet Protocols and Support" >next</a> |</li> <li class="right" > <a href="xml.sax.reader.html" title="xml.sax.xmlreader — Interface for XML parsers" >previous</a> |</li> <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li class="switchers"> <div class="language_switcher_placeholder"></div> <div class="version_switcher_placeholder"></div> </li> <li> </li> <li id="cpython-language-and-version"> <a href="../index.html">3.10.12 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" >Structured Markup Processing Tools</a> »</li> <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.parsers.expat</span></code> — Fast XML parsing using Expat</a></li> <li class="right"> <div class="inline-search" role="search"> <form class="inline-search" action="../search.html" method="get"> <input placeholder="Quick search" aria-label="Quick search" type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> | </li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 2001-2026, Python Software Foundation. <br /> This page is licensed under the Python Software Foundation License Version 2. <br /> Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License. <br /> See <a href="/license.html">History and License</a> for more information.<br /> <br /> The Python Software Foundation is a non-profit corporation. <a href="https://www.python.org/psf/donations/">Please donate.</a> <br /> <br /> Last updated on January 26, 2026. <a href="/bugs.html">Found a bug</a>? <br /> Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2. </div> </body> </html>
Close