/
usr
/
share
/
doc
/
python3-docs
/
html
/
library
/
/usr/share/doc/python3-docs/html/library
mkdir
upload
Name
Size
Mode
Actions
2to3.html
61709
0644
edit
dl
rm
abc.html
41394
0644
edit
dl
rm
aifc.html
28114
0644
edit
dl
rm
allos.html
32236
0644
edit
dl
rm
archiving.html
11992
0644
edit
dl
rm
argparse.html
274984
0644
edit
dl
rm
array.html
33547
0644
edit
dl
rm
ast.html
39595
0644
edit
dl
rm
asynchat.html
32546
0644
edit
dl
rm
asyncio-dev.html
51869
0644
edit
dl
rm
asyncio-eventloop.html
111215
0644
edit
dl
rm
asyncio-eventloops.html
33026
0644
edit
dl
rm
asyncio-protocol.html
87431
0644
edit
dl
rm
asyncio-queue.html
23957
0644
edit
dl
rm
asyncio-stream.html
61005
0644
edit
dl
rm
asyncio-subprocess.html
58015
0644
edit
dl
rm
asyncio-sync.html
35678
0644
edit
dl
rm
asyncio-task.html
83968
0644
edit
dl
rm
asyncio.html
28026
0644
edit
dl
rm
asyncore.html
42706
0644
edit
dl
rm
atexit.html
18433
0644
edit
dl
rm
audioop.html
35442
0644
edit
dl
rm
base64.html
36454
0644
edit
dl
rm
bdb.html
43423
0644
edit
dl
rm
binary.html
12723
0644
edit
dl
rm
binascii.html
24745
0644
edit
dl
rm
binhex.html
11669
0644
edit
dl
rm
bisect.html
25602
0644
edit
dl
rm
builtins.html
11604
0644
edit
dl
rm
bz2.html
33358
0644
edit
dl
rm
calendar.html
39539
0644
edit
dl
rm
cgi.html
55881
0644
edit
dl
rm
cgitb.html
12765
0644
edit
dl
rm
chunk.html
16872
0644
edit
dl
rm
cmath.html
34171
0644
edit
dl
rm
cmd.html
43811
0644
edit
dl
rm
code.html
27886
0644
edit
dl
rm
codecs.html
134071
0644
edit
dl
rm
codeop.html
14304
0644
edit
dl
rm
collections.abc.html
60912
0644
edit
dl
rm
collections.html
154946
0644
edit
dl
rm
colorsys.html
12627
0644
edit
dl
rm
compileall.html
28263
0644
edit
dl
rm
concurrency.html
21203
0644
edit
dl
rm
concurrent.futures.html
60660
0644
edit
dl
rm
concurrent.html
7959
0644
edit
dl
rm
configparser.html
141052
0644
edit
dl
rm
constants.html
17500
0644
edit
dl
rm
contextlib.html
88801
0644
edit
dl
rm
copy.html
13841
0644
edit
dl
rm
copyreg.html
14725
0644
edit
dl
rm
crypt.html
20331
0644
edit
dl
rm
crypto.html
10914
0644
edit
dl
rm
csv.html
69043
0644
edit
dl
rm
ctypes.html
264529
0644
edit
dl
rm
curses.ascii.html
25197
0644
edit
dl
rm
curses.html
175551
0644
edit
dl
rm
curses.panel.html
16706
0644
edit
dl
rm
custominterp.html
8734
0644
edit
dl
rm
datatypes.html
23950
0644
edit
dl
rm
datetime.html
306435
0644
edit
dl
rm
dbm.html
43119
0644
edit
dl
rm
debug.html
13983
0644
edit
dl
rm
decimal.html
233486
0644
edit
dl
rm
development.html
25123
0644
edit
dl
rm
difflib.html
96156
0644
edit
dl
rm
dis.html
106191
0644
edit
dl
rm
distribution.html
10506
0644
edit
dl
rm
distutils.html
10884
0644
edit
dl
rm
doctest.html
179752
0644
edit
dl
rm
dummy_threading.html
9316
0644
edit
dl
rm
email.charset.html
26431
0644
edit
dl
rm
email.compat32-message.html
86150
0644
edit
dl
rm
email.contentmanager.html
30028
0644
edit
dl
rm
email.encoders.html
14250
0644
edit
dl
rm
email.errors.html
19704
0644
edit
dl
rm
email.examples.html
57872
0644
edit
dl
rm
email.generator.html
41798
0644
edit
dl
rm
email.header.html
31219
0644
edit
dl
rm
email.headerregistry.html
57670
0644
edit
dl
rm
email.html
27741
0644
edit
dl
rm
email.iterators.html
13532
0644
edit
dl
rm
email.message.html
87210
0644
edit
dl
rm
email.mime.html
36081
0644
edit
dl
rm
email.parser.html
47430
0644
edit
dl
rm
email.policy.html
75241
0644
edit
dl
rm
email.util.html
33853
0644
edit
dl
rm
ensurepip.html
18700
0644
edit
dl
rm
enum.html
133949
0644
edit
dl
rm
errno.html
41331
0644
edit
dl
rm
exceptions.html
85151
0644
edit
dl
rm
faulthandler.html
23396
0644
edit
dl
rm
fcntl.html
27321
0644
edit
dl
rm
filecmp.html
25036
0644
edit
dl
rm
fileformats.html
11129
0644
edit
dl
rm
fileinput.html
30030
0644
edit
dl
rm
filesys.html
13418
0644
edit
dl
rm
fnmatch.html
16987
0644
edit
dl
rm
formatter.html
37666
0644
edit
dl
rm
fpectl.html
17538
0644
edit
dl
rm
fractions.html
29918
0644
edit
dl
rm
frameworks.html
13471
0644
edit
dl
rm
ftplib.html
54429
0644
edit
dl
rm
functional.html
9002
0644
edit
dl
rm
functions.html
201486
0644
edit
dl
rm
functools.html
64951
0644
edit
dl
rm
gc.html
29524
0644
edit
dl
rm
getopt.html
25353
0644
edit
dl
rm
getpass.html
12061
0644
edit
dl
rm
gettext.html
76641
0644
edit
dl
rm
glob.html
18432
0644
edit
dl
rm
grp.html
12383
0644
edit
dl
rm
gzip.html
32669
0644
edit
dl
rm
hashlib.html
79554
0644
edit
dl
rm
heapq.html
35529
0644
edit
dl
rm
hmac.html
17827
0644
edit
dl
rm
html.entities.html
11361
0644
edit
dl
rm
html.html
11108
0644
edit
dl
rm
html.parser.html
41842
0644
edit
dl
rm
http.client.html
65250
0644
edit
dl
rm
http.cookiejar.html
96195
0644
edit
dl
rm
http.cookies.html
39329
0644
edit
dl
rm
http.html
37602
0644
edit
dl
rm
http.server.html
58191
0644
edit
dl
rm
i18n.html
10464
0644
edit
dl
rm
idle.html
48412
0644
edit
dl
rm
imaplib.html
67339
0644
edit
dl
rm
imghdr.html
13456
0644
edit
dl
rm
imp.html
48153
0644
edit
dl
rm
importlib.html
173109
0644
edit
dl
rm
index.html
67768
0644
edit
dl
rm
inspect.html
130355
0644
edit
dl
rm
internet.html
31087
0644
edit
dl
rm
intro.html
9904
0644
edit
dl
rm
io.html
122685
0644
edit
dl
rm
ipaddress.html
105873
0644
edit
dl
rm
ipc.html
33743
0644
edit
dl
rm
itertools.html
132824
0644
edit
dl
rm
json.html
81078
0644
edit
dl
rm
keyword.html
8918
0644
edit
dl
rm
language.html
13648
0644
edit
dl
rm
linecache.html
13492
0644
edit
dl
rm
locale.html
61540
0644
edit
dl
rm
logging.config.html
85489
0644
edit
dl
rm
logging.handlers.html
112397
0644
edit
dl
rm
logging.html
134850
0644
edit
dl
rm
lzma.html
56484
0644
edit
dl
rm
macpath.html
9257
0644
edit
dl
rm
mailbox.html
157315
0644
edit
dl
rm
mailcap.html
14676
0644
edit
dl
rm
markup.html
19356
0644
edit
dl
rm
marshal.html
18317
0644
edit
dl
rm
math.html
53661
0644
edit
dl
rm
mimetypes.html
31410
0644
edit
dl
rm
misc.html
8123
0644
edit
dl
rm
mm.html
10022
0644
edit
dl
rm
mmap.html
34294
0644
edit
dl
rm
modulefinder.html
18559
0644
edit
dl
rm
modules.html
10914
0644
edit
dl
rm
msilib.html
57205
0644
edit
dl
rm
msvcrt.html
21989
0644
edit
dl
rm
multiprocessing.html
365487
0644
edit
dl
rm
netdata.html
17470
0644
edit
dl
rm
netrc.html
14568
0644
edit
dl
rm
nis.html
11659
0644
edit
dl
rm
nntplib.html
69601
0644
edit
dl
rm
numbers.html
41432
0644
edit
dl
rm
numeric.html
15535
0644
edit
dl
rm
operator.html
81460
0644
edit
dl
rm
optparse.html
249942
0644
edit
dl
rm
os.html
398039
0644
edit
dl
rm
os.path.html
53818
0644
edit
dl
rm
ossaudiodev.html
47947
0644
edit
dl
rm
othergui.html
10256
0644
edit
dl
rm
parser.html
42408
0644
edit
dl
rm
pathlib.html
116726
0644
edit
dl
rm
pdb.html
52661
0644
edit
dl
rm
persistence.html
15281
0644
edit
dl
rm
pickle.html
115052
0644
edit
dl
rm
pickletools.html
17094
0644
edit
dl
rm
pipes.html
15991
0644
edit
dl
rm
pkgutil.html
31878
0644
edit
dl
rm
platform.html
33728
0644
edit
dl
rm
plistlib.html
29290
0644
edit
dl
rm
poplib.html
30940
0644
edit
dl
rm
posix.html
17608
0644
edit
dl
rm
pprint.html
41969
0644
edit
dl
rm
profile.html
71848
0644
edit
dl
rm
pty.html
17594
0644
edit
dl
rm
pwd.html
13098
0644
edit
dl
rm
pyclbr.html
16520
0644
edit
dl
rm
pydoc.html
15991
0644
edit
dl
rm
pyexpat.html
88938
0644
edit
dl
rm
python.html
17133
0644
edit
dl
rm
py_compile.html
15508
0644
edit
dl
rm
queue.html
28199
0644
edit
dl
rm
quopri.html
13858
0644
edit
dl
rm
random.html
60646
0644
edit
dl
rm
re.html
191176
0644
edit
dl
rm
readline.html
42133
0644
edit
dl
rm
reprlib.html
24964
0644
edit
dl
rm
resource.html
36552
0644
edit
dl
rm
rlcompleter.html
14392
0644
edit
dl
rm
runpy.html
26607
0644
edit
dl
rm
sched.html
20034
0644
edit
dl
rm
secrets.html
24734
0644
edit
dl
rm
select.html
62819
0644
edit
dl
rm
selectors.html
35845
0644
edit
dl
rm
shelve.html
28777
0644
edit
dl
rm
shlex.html
48979
0644
edit
dl
rm
shutil.html
74207
0644
edit
dl
rm
signal.html
55064
0644
edit
dl
rm
site.html
32242
0644
edit
dl
rm
smtpd.html
35892
0644
edit
dl
rm
smtplib.html
68433
0644
edit
dl
rm
sndhdr.html
12439
0644
edit
dl
rm
socket.html
196077
0644
edit
dl
rm
socketserver.html
81918
0644
edit
dl
rm
spwd.html
12328
0644
edit
dl
rm
sqlite3.html
161872
0644
edit
dl
rm
ssl.html
266327
0644
edit
dl
rm
stat.html
44722
0644
edit
dl
rm
statistics.html
50050
0644
edit
dl
rm
stdtypes.html
465658
0644
edit
dl
rm
string.html
95262
0644
edit
dl
rm
stringprep.html
18654
0644
edit
dl
rm
struct.html
51100
0644
edit
dl
rm
subprocess.html
141926
0644
edit
dl
rm
sunau.html
31757
0644
edit
dl
rm
superseded.html
13781
0644
edit
dl
rm
symbol.html
8848
0644
edit
dl
rm
symtable.html
26112
0644
edit
dl
rm
sys.html
141670
0644
edit
dl
rm
sysconfig.html
30259
0644
edit
dl
rm
syslog.html
21026
0644
edit
dl
rm
tabnanny.html
12269
0644
edit
dl
rm
tarfile.html
96758
0644
edit
dl
rm
telnetlib.html
30409
0644
edit
dl
rm
tempfile.html
41394
0644
edit
dl
rm
termios.html
18181
0644
edit
dl
rm
test.html
78555
0644
edit
dl
rm
text.html
13786
0644
edit
dl
rm
textwrap.html
37998
0644
edit
dl
rm
threading.html
103464
0644
edit
dl
rm
time.html
79629
0644
edit
dl
rm
timeit.html
45249
0644
edit
dl
rm
tk.html
23299
0644
edit
dl
rm
tkinter.html
82932
0644
edit
dl
rm
tkinter.scrolledtext.html
9957
0644
edit
dl
rm
tkinter.tix.html
51858
0644
edit
dl
rm
tkinter.ttk.html
110673
0644
edit
dl
rm
token.html
22660
0644
edit
dl
rm
tokenize.html
32149
0644
edit
dl
rm
trace.html
29145
0644
edit
dl
rm
traceback.html
57588
0644
edit
dl
rm
tracemalloc.html
101144
0644
edit
dl
rm
tty.html
10540
0644
edit
dl
rm
turtle.html
250367
0644
edit
dl
rm
types.html
37060
0644
edit
dl
rm
typing.html
139175
0644
edit
dl
rm
undoc.html
9181
0644
edit
dl
rm
unicodedata.html
21108
0644
edit
dl
rm
unittest.html
250689
0644
edit
dl
rm
unittest.mock-examples.html
168144
0644
edit
dl
rm
unittest.mock.html
300089
0644
edit
dl
rm
unix.html
11780
0644
edit
dl
rm
urllib.error.html
14474
0644
edit
dl
rm
urllib.html
9566
0644
edit
dl
rm
urllib.parse.html
76334
0644
edit
dl
rm
urllib.request.html
177199
0644
edit
dl
rm
urllib.robotparser.html
17156
0644
edit
dl
rm
uu.html
12209
0644
edit
dl
rm
uuid.html
31957
0644
edit
dl
rm
venv.html
73909
0644
edit
dl
rm
warnings.html
50320
0644
edit
dl
rm
wave.html
29868
0644
edit
dl
rm
weakref.html
65292
0644
edit
dl
rm
webbrowser.html
26901
0644
edit
dl
rm
windows.html
10626
0644
edit
dl
rm
winreg.html
66730
0644
edit
dl
rm
winsound.html
21268
0644
edit
dl
rm
wsgiref.html
94492
0644
edit
dl
rm
xdrlib.html
33751
0644
edit
dl
rm
xml.dom.html
97570
0644
edit
dl
rm
xml.dom.minidom.html
41481
0644
edit
dl
rm
xml.dom.pulldom.html
24214
0644
edit
dl
rm
xml.etree.elementtree.html
135491
0644
edit
dl
rm
xml.html
19261
0644
edit
dl
rm
xml.sax.handler.html
42659
0644
edit
dl
rm
xml.sax.html
25515
0644
edit
dl
rm
xml.sax.reader.html
45869
0644
edit
dl
rm
xml.sax.utils.html
16928
0644
edit
dl
rm
xmlrpc.client.html
71947
0644
edit
dl
rm
xmlrpc.html
8535
0644
edit
dl
rm
xmlrpc.server.html
49195
0644
edit
dl
rm
zipapp.html
45105
0644
edit
dl
rm
zipfile.html
80039
0644
edit
dl
rm
zipimport.html
23052
0644
edit
dl
rm
zlib.html
34557
0644
edit
dl
rm
_dummy_thread.html
9193
0644
edit
dl
rm
_thread.html
22588
0644
edit
dl
rm
__future__.html
15792
0644
edit
dl
rm
__main__.html
9019
0644
edit
dl
rm
Edit:
/usr/share/doc/python3-docs/html/library/pyexpat.html
(88938B)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>20.13. xml.parsers.expat — Fast XML parsing using Expat — Python 3.6.7 documentation</title> <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 3.6.7 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="21. Internet Protocols and Support" href="internet.html" /> <link rel="prev" title="20.12. xml.sax.xmlreader — Interface for XML parsers" href="xml.sax.reader.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <link rel="canonical" href="https://docs.python.org/3/library/pyexpat.html" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head><body> <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="21. Internet Protocols and Support" accesskey="N">next</a> |</li> <li class="right" > <a href="xml.sax.reader.html" title="20.12. xml.sax.xmlreader — Interface for XML parsers" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li> <a href="../index.html">3.6.7 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">20. Structured Markup Processing Tools</a> »</li> <li class="right"> <div class="inline-search" style="display: none" role="search"> <form class="inline-search" action="../search.html" method="get"> <input placeholder="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> <script type="text/javascript">$('.inline-search').show(0);</script> | </li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="module-xml.parsers.expat"> <span id="xml-parsers-expat-fast-xml-parsing-using-expat"></span><h1>20.13. <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="first admonition-title">Warning</p> <p class="last">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="exception"> <dt id="xml.parsers.expat.ExpatError"> <em class="property">exception </em><code class="descclassname">xml.parsers.expat.</code><code class="descname">ExpatError</code><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="exception"> <dt id="xml.parsers.expat.error"> <em class="property">exception </em><code class="descclassname">xml.parsers.expat.</code><code class="descname">error</code><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="data"> <dt id="xml.parsers.expat.XMLParserType"> <code class="descclassname">xml.parsers.expat.</code><code class="descname">XMLParserType</code><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="function"> <dt id="xml.parsers.expat.ErrorString"> <code class="descclassname">xml.parsers.expat.</code><code class="descname">ErrorString</code><span class="sig-paren">(</span><em>errno</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="function"> <dt id="xml.parsers.expat.ParserCreate"> <code class="descclassname">xml.parsers.expat.</code><code class="descname">ParserCreate</code><span class="sig-paren">(</span><em>encoding=None</em>, <em>namespace_separator=None</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" 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="first admonition-title">See also</p> <dl class="last docutils"> <dt><a class="reference external" href="http://www.libexpat.org/">The Expat XML Parser</a></dt> <dd>Home page of the Expat project.</dd> </dl> </div> <div class="section" id="xmlparser-objects"> <span id="id2"></span><h2>20.13.1. 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="method"> <dt id="xml.parsers.expat.xmlparser.Parse"> <code class="descclassname">xmlparser.</code><code class="descname">Parse</code><span class="sig-paren">(</span><em>data</em><span class="optional">[</span>, <em>isfinal</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="method"> <dt id="xml.parsers.expat.xmlparser.ParseFile"> <code class="descclassname">xmlparser.</code><code class="descname">ParseFile</code><span class="sig-paren">(</span><em>file</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="method"> <dt id="xml.parsers.expat.xmlparser.SetBase"> <code class="descclassname">xmlparser.</code><code class="descname">SetBase</code><span class="sig-paren">(</span><em>base</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="method"> <dt id="xml.parsers.expat.xmlparser.GetBase"> <code class="descclassname">xmlparser.</code><code class="descname">GetBase</code><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="method"> <dt id="xml.parsers.expat.xmlparser.GetInputContext"> <code class="descclassname">xmlparser.</code><code class="descname">GetInputContext</code><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="method"> <dt id="xml.parsers.expat.xmlparser.ExternalEntityParserCreate"> <code class="descclassname">xmlparser.</code><code class="descname">ExternalEntityParserCreate</code><span class="sig-paren">(</span><em>context</em><span class="optional">[</span>, <em>encoding</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="method"> <dt id="xml.parsers.expat.xmlparser.SetParamEntityParsing"> <code class="descclassname">xmlparser.</code><code class="descname">SetParamEntityParsing</code><span class="sig-paren">(</span><em>flag</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="method"> <dt id="xml.parsers.expat.xmlparser.UseForeignDTD"> <code class="descclassname">xmlparser.</code><code class="descname">UseForeignDTD</code><span class="sig-paren">(</span><span class="optional">[</span><em>flag</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="attribute"> <dt id="xml.parsers.expat.xmlparser.buffer_size"> <code class="descclassname">xmlparser.</code><code class="descname">buffer_size</code><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="attribute"> <dt id="xml.parsers.expat.xmlparser.buffer_text"> <code class="descclassname">xmlparser.</code><code class="descname">buffer_text</code><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="attribute"> <dt id="xml.parsers.expat.xmlparser.buffer_used"> <code class="descclassname">xmlparser.</code><code class="descname">buffer_used</code><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="attribute"> <dt id="xml.parsers.expat.xmlparser.ordered_attributes"> <code class="descclassname">xmlparser.</code><code class="descname">ordered_attributes</code><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="attribute"> <dt id="xml.parsers.expat.xmlparser.specified_attributes"> <code class="descclassname">xmlparser.</code><code class="descname">specified_attributes</code><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="attribute"> <dt id="xml.parsers.expat.xmlparser.ErrorByteIndex"> <code class="descclassname">xmlparser.</code><code class="descname">ErrorByteIndex</code><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="attribute"> <dt id="xml.parsers.expat.xmlparser.ErrorCode"> <code class="descclassname">xmlparser.</code><code class="descname">ErrorCode</code><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="attribute"> <dt id="xml.parsers.expat.xmlparser.ErrorColumnNumber"> <code class="descclassname">xmlparser.</code><code class="descname">ErrorColumnNumber</code><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="attribute"> <dt id="xml.parsers.expat.xmlparser.ErrorLineNumber"> <code class="descclassname">xmlparser.</code><code class="descname">ErrorLineNumber</code><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="attribute"> <dt id="xml.parsers.expat.xmlparser.CurrentByteIndex"> <code class="descclassname">xmlparser.</code><code class="descname">CurrentByteIndex</code><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="attribute"> <dt id="xml.parsers.expat.xmlparser.CurrentColumnNumber"> <code class="descclassname">xmlparser.</code><code class="descname">CurrentColumnNumber</code><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="attribute"> <dt id="xml.parsers.expat.xmlparser.CurrentLineNumber"> <code class="descclassname">xmlparser.</code><code class="descname">CurrentLineNumber</code><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="method"> <dt id="xml.parsers.expat.xmlparser.XmlDeclHandler"> <code class="descclassname">xmlparser.</code><code class="descname">XmlDeclHandler</code><span class="sig-paren">(</span><em>version</em>, <em>encoding</em>, <em>standalone</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="method"> <dt id="xml.parsers.expat.xmlparser.StartDoctypeDeclHandler"> <code class="descclassname">xmlparser.</code><code class="descname">StartDoctypeDeclHandler</code><span class="sig-paren">(</span><em>doctypeName</em>, <em>systemId</em>, <em>publicId</em>, <em>has_internal_subset</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="method"> <dt id="xml.parsers.expat.xmlparser.EndDoctypeDeclHandler"> <code class="descclassname">xmlparser.</code><code class="descname">EndDoctypeDeclHandler</code><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="method"> <dt id="xml.parsers.expat.xmlparser.ElementDeclHandler"> <code class="descclassname">xmlparser.</code><code class="descname">ElementDeclHandler</code><span class="sig-paren">(</span><em>name</em>, <em>model</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="method"> <dt id="xml.parsers.expat.xmlparser.AttlistDeclHandler"> <code class="descclassname">xmlparser.</code><code class="descname">AttlistDeclHandler</code><span class="sig-paren">(</span><em>elname</em>, <em>attname</em>, <em>type</em>, <em>default</em>, <em>required</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="method"> <dt id="xml.parsers.expat.xmlparser.StartElementHandler"> <code class="descclassname">xmlparser.</code><code class="descname">StartElementHandler</code><span class="sig-paren">(</span><em>name</em>, <em>attributes</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="method"> <dt id="xml.parsers.expat.xmlparser.EndElementHandler"> <code class="descclassname">xmlparser.</code><code class="descname">EndElementHandler</code><span class="sig-paren">(</span><em>name</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="method"> <dt id="xml.parsers.expat.xmlparser.ProcessingInstructionHandler"> <code class="descclassname">xmlparser.</code><code class="descname">ProcessingInstructionHandler</code><span class="sig-paren">(</span><em>target</em>, <em>data</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="method"> <dt id="xml.parsers.expat.xmlparser.CharacterDataHandler"> <code class="descclassname">xmlparser.</code><code class="descname">CharacterDataHandler</code><span class="sig-paren">(</span><em>data</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="method"> <dt id="xml.parsers.expat.xmlparser.UnparsedEntityDeclHandler"> <code class="descclassname">xmlparser.</code><code class="descname">UnparsedEntityDeclHandler</code><span class="sig-paren">(</span><em>entityName</em>, <em>base</em>, <em>systemId</em>, <em>publicId</em>, <em>notationName</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="method"> <dt id="xml.parsers.expat.xmlparser.EntityDeclHandler"> <code class="descclassname">xmlparser.</code><code class="descname">EntityDeclHandler</code><span class="sig-paren">(</span><em>entityName</em>, <em>is_parameter_entity</em>, <em>value</em>, <em>base</em>, <em>systemId</em>, <em>publicId</em>, <em>notationName</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="method"> <dt id="xml.parsers.expat.xmlparser.NotationDeclHandler"> <code class="descclassname">xmlparser.</code><code class="descname">NotationDeclHandler</code><span class="sig-paren">(</span><em>notationName</em>, <em>base</em>, <em>systemId</em>, <em>publicId</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="method"> <dt id="xml.parsers.expat.xmlparser.StartNamespaceDeclHandler"> <code class="descclassname">xmlparser.</code><code class="descname">StartNamespaceDeclHandler</code><span class="sig-paren">(</span><em>prefix</em>, <em>uri</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="method"> <dt id="xml.parsers.expat.xmlparser.EndNamespaceDeclHandler"> <code class="descclassname">xmlparser.</code><code class="descname">EndNamespaceDeclHandler</code><span class="sig-paren">(</span><em>prefix</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="method"> <dt id="xml.parsers.expat.xmlparser.CommentHandler"> <code class="descclassname">xmlparser.</code><code class="descname">CommentHandler</code><span class="sig-paren">(</span><em>data</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="method"> <dt id="xml.parsers.expat.xmlparser.StartCdataSectionHandler"> <code class="descclassname">xmlparser.</code><code class="descname">StartCdataSectionHandler</code><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="method"> <dt id="xml.parsers.expat.xmlparser.EndCdataSectionHandler"> <code class="descclassname">xmlparser.</code><code class="descname">EndCdataSectionHandler</code><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="method"> <dt id="xml.parsers.expat.xmlparser.DefaultHandler"> <code class="descclassname">xmlparser.</code><code class="descname">DefaultHandler</code><span class="sig-paren">(</span><em>data</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="method"> <dt id="xml.parsers.expat.xmlparser.DefaultHandlerExpand"> <code class="descclassname">xmlparser.</code><code class="descname">DefaultHandlerExpand</code><span class="sig-paren">(</span><em>data</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="method"> <dt id="xml.parsers.expat.xmlparser.NotStandaloneHandler"> <code class="descclassname">xmlparser.</code><code class="descname">NotStandaloneHandler</code><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="method"> <dt id="xml.parsers.expat.xmlparser.ExternalEntityRefHandler"> <code class="descclassname">xmlparser.</code><code class="descname">ExternalEntityRefHandler</code><span class="sig-paren">(</span><em>context</em>, <em>base</em>, <em>systemId</em>, <em>publicId</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> </div> <div class="section" id="expaterror-exceptions"> <span id="expaterror-objects"></span><h2>20.13.2. 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="attribute"> <dt id="xml.parsers.expat.ExpatError.code"> <code class="descclassname">ExpatError.</code><code class="descname">code</code><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="k">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="attribute"> <dt id="xml.parsers.expat.ExpatError.lineno"> <code class="descclassname">ExpatError.</code><code class="descname">lineno</code><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="attribute"> <dt id="xml.parsers.expat.ExpatError.offset"> <code class="descclassname">ExpatError.</code><code class="descname">offset</code><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> </div> <div class="section" id="example"> <span id="expat-example"></span><h2>20.13.3. 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> </div> <div class="section" id="module-xml.parsers.expat.model"> <span id="content-model-descriptions"></span><span id="expat-content-models"></span><h2>20.13.4. 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="data"> <dt> <code class="descclassname">xml.parsers.expat.model.</code><code class="descname">XML_CTYPE_ANY</code></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="data"> <dt> <code class="descclassname">xml.parsers.expat.model.</code><code class="descname">XML_CTYPE_CHOICE</code></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="data"> <dt> <code class="descclassname">xml.parsers.expat.model.</code><code class="descname">XML_CTYPE_EMPTY</code></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="data"> <dt> <code class="descclassname">xml.parsers.expat.model.</code><code class="descname">XML_CTYPE_MIXED</code></dt> <dd></dd></dl> <dl class="data"> <dt> <code class="descclassname">xml.parsers.expat.model.</code><code class="descname">XML_CTYPE_NAME</code></dt> <dd></dd></dl> <dl class="data"> <dt> <code class="descclassname">xml.parsers.expat.model.</code><code class="descname">XML_CTYPE_SEQ</code></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="data"> <dt> <code class="descclassname">xml.parsers.expat.model.</code><code class="descname">XML_CQUANT_NONE</code></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="data"> <dt> <code class="descclassname">xml.parsers.expat.model.</code><code class="descname">XML_CQUANT_OPT</code></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="data"> <dt> <code class="descclassname">xml.parsers.expat.model.</code><code class="descname">XML_CQUANT_PLUS</code></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="data"> <dt> <code class="descclassname">xml.parsers.expat.model.</code><code class="descname">XML_CQUANT_REP</code></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> </div> <div class="section" id="module-xml.parsers.expat.errors"> <span id="expat-error-constants"></span><span id="expat-errors"></span><h2>20.13.5. 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="data"> <dt id="xml.parsers.expat.errors.codes"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">codes</code><a class="headerlink" href="#xml.parsers.expat.errors.codes" 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">New in version 3.2.</span></p> </div> </dd></dl> <dl class="data"> <dt id="xml.parsers.expat.errors.messages"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">messages</code><a class="headerlink" href="#xml.parsers.expat.errors.messages" 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">New in version 3.2.</span></p> </div> </dd></dl> <dl class="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_ASYNC_ENTITY"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_ASYNC_ENTITY</code><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_ASYNC_ENTITY" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_BAD_CHAR_REF"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_BAD_CHAR_REF</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_BINARY_ENTITY_REF"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_BINARY_ENTITY_REF</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_DUPLICATE_ATTRIBUTE"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_DUPLICATE_ATTRIBUTE</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_INCORRECT_ENCODING"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_INCORRECT_ENCODING</code><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_INCORRECT_ENCODING" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_INVALID_TOKEN"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_INVALID_TOKEN</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_JUNK_AFTER_DOC_ELEMENT"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_JUNK_AFTER_DOC_ELEMENT</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_MISPLACED_XML_PI"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_MISPLACED_XML_PI</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_NO_ELEMENTS"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_NO_ELEMENTS</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_NO_MEMORY"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_NO_MEMORY</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_PARAM_ENTITY_REF"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_PARAM_ENTITY_REF</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_PARTIAL_CHAR"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_PARTIAL_CHAR</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_RECURSIVE_ENTITY_REF"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_RECURSIVE_ENTITY_REF</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_SYNTAX"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_SYNTAX</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_TAG_MISMATCH"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_TAG_MISMATCH</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_UNCLOSED_TOKEN"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_UNCLOSED_TOKEN</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_UNDEFINED_ENTITY"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_UNDEFINED_ENTITY</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_UNKNOWN_ENCODING"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_UNKNOWN_ENCODING</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_UNCLOSED_CDATA_SECTION"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_UNCLOSED_CDATA_SECTION</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_EXTERNAL_ENTITY_HANDLING"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_EXTERNAL_ENTITY_HANDLING</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_NOT_STANDALONE"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_NOT_STANDALONE</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_UNEXPECTED_STATE"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_UNEXPECTED_STATE</code><a class="headerlink" href="#xml.parsers.expat.errors.XML_ERROR_UNEXPECTED_STATE" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_ENTITY_DECLARED_IN_PE"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_ENTITY_DECLARED_IN_PE</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_FEATURE_REQUIRES_XML_DTD"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_FEATURE_REQUIRES_XML_DTD</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_UNBOUND_PREFIX"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_UNBOUND_PREFIX</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_UNDECLARING_PREFIX"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_UNDECLARING_PREFIX</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_INCOMPLETE_PE"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_INCOMPLETE_PE</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_XML_DECL"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_XML_DECL</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_TEXT_DECL"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_TEXT_DECL</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_PUBLICID"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_PUBLICID</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_SUSPENDED"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_SUSPENDED</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_NOT_SUSPENDED"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_NOT_SUSPENDED</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_ABORTED"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_ABORTED</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_FINISHED"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_FINISHED</code><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="data"> <dt id="xml.parsers.expat.errors.XML_ERROR_SUSPEND_PE"> <code class="descclassname">xml.parsers.expat.errors.</code><code class="descname">XML_ERROR_SUSPEND_PE</code><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> <table class="docutils footnote" frame="void" id="id3" rules="none"> <colgroup><col class="label" /><col /></colgroup> <tbody valign="top"> <tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>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>.</td></tr> </tbody> </table> </div> </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="#">20.13. <code class="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">20.13.1. XMLParser Objects</a></li> <li><a class="reference internal" href="#expaterror-exceptions">20.13.2. ExpatError Exceptions</a></li> <li><a class="reference internal" href="#example">20.13.3. Example</a></li> <li><a class="reference internal" href="#module-xml.parsers.expat.model">20.13.4. Content Model Descriptions</a></li> <li><a class="reference internal" href="#module-xml.parsers.expat.errors">20.13.5. Expat error constants</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="xml.sax.reader.html" title="previous chapter">20.12. <code class="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">21. 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.6/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="21. Internet Protocols and Support" >next</a> |</li> <li class="right" > <a href="xml.sax.reader.html" title="20.12. xml.sax.xmlreader — Interface for XML parsers" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li> <a href="../index.html">3.6.7 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" >20. Structured Markup Processing Tools</a> »</li> <li class="right"> <div class="inline-search" style="display: none" role="search"> <form class="inline-search" action="../search.html" method="get"> <input placeholder="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> <script type="text/javascript">$('.inline-search').show(0);</script> | </li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 2001-2023, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="https://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Dec 18, 2023. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.7.6. </div> </body> </html>
Save
cmd:
run