📄 module-xmlsaxsaxutils.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>13.7 xml.sax.saxutils -- SAX Utilities</title>
<META NAME="description" CONTENT="13.7 xml.sax.saxutils -- SAX Utilities">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="module-xml.sax.xmlreader.html" tppabs="http://www.python.org/doc/current/lib/module-xml.sax.xmlreader.html">
<LINK REL="previous" href="module-xml.sax.handler.html" tppabs="http://www.python.org/doc/current/lib/module-xml.sax.handler.html">
<LINK REL="up" href="markup.html" tppabs="http://www.python.org/doc/current/lib/markup.html">
<LINK REL="next" href="module-xml.sax.xmlreader.html" tppabs="http://www.python.org/doc/current/lib/module-xml.sax.xmlreader.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="entity-resolver-objects.html" tppabs="http://www.python.org/doc/current/lib/entity-resolver-objects.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="markup.html" tppabs="http://www.python.org/doc/current/lib/markup.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="module-xml.sax.xmlreader.html" tppabs="http://www.python.org/doc/current/lib/module-xml.sax.xmlreader.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="entity-resolver-objects.html" tppabs="http://www.python.org/doc/current/lib/entity-resolver-objects.html">13.6.3 EntityResolver Objects</A>
<b class="navlabel">Up:</b> <a class="sectref" href="markup.html" tppabs="http://www.python.org/doc/current/lib/markup.html">13. Structured Markup Processing</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-xml.sax.xmlreader.html" tppabs="http://www.python.org/doc/current/lib/module-xml.sax.xmlreader.html">13.8 xml.sax.xmlreader </A>
<br><hr></DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION0015700000000000000000">
13.7 <tt class="module">xml.sax.saxutils</tt> --
SAX Utilities</A>
</H1>
<P>
<P>
New in version 2.0.
<P>
The module <tt class="module">xml.sax.saxutils</tt> contains a number of classes and
functions that are commonly useful when creating SAX applications,
either in direct use, or as base classes.
<P>
<dl><dt><b><a name='l2h-2683'><tt class='function'>escape</tt></a></b> (<var>data</var><big>[</big><var>, entities</var><big>]</big>)
<dd>
Escape &, <, and > in a string of data.
<P>
You can escape other strings of data by passing a dictionary as the
optional entities parameter. The keys and values must all be
strings; each key will be replaced with its corresponding value.
</dl>
<P>
<dl><dt><b><a name='l2h-2684'><tt class='class'>XMLGenerator</tt></a></b> (<big>[</big><var>out</var><big>[</big><var>, encoding</var><big>]</big><big>]</big>)
<dd>
This class implements the <tt class="class">ContentHandler</tt> interface by
writing SAX events back into an XML document. In other words, using
an <tt class="class">XMLGenerator</tt> as the content handler will reproduce the
original document being parsed. <var>out</var> should be a file-like
object which will default to <var>sys.stdout</var>. <var>encoding</var> is the
encoding of the output stream which defaults to <code>'iso-8859-1'</code>.
</dl>
<P>
<dl><dt><b><a name='l2h-2685'><tt class='class'>XMLFilterBase</tt></a></b> (<var>base</var>)
<dd>
This class is designed to sit between an <tt class="class">XMLReader</tt> and the
client application's event handlers. By default, it does nothing
but pass requests up to the reader and events on to the handlers
unmodified, but subclasses can override specific methods to modify
the event stream or the configuration requests as they pass through.
</dl>
<P>
<dl><dt><b><a name='l2h-2686'><tt class='function'>prepare_input_source</tt></a></b> (<var>source</var><big>[</big><var>, base</var><big>]</big>)
<dd>
This function takes an input source and an optional base URL and
returns a fully resolved <tt class="class">InputSource</tt> object ready for
reading. The input source can be given as a string, a file-like
object, or an <tt class="class">InputSource</tt> object; parsers will use this
function to implement the polymorphic <var>source</var> argument to their
<tt class="method">parse()</tt> method.
</dl>
<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="entity-resolver-objects.html" tppabs="http://www.python.org/doc/current/lib/entity-resolver-objects.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="markup.html" tppabs="http://www.python.org/doc/current/lib/markup.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="module-xml.sax.xmlreader.html" tppabs="http://www.python.org/doc/current/lib/module-xml.sax.xmlreader.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="entity-resolver-objects.html" tppabs="http://www.python.org/doc/current/lib/entity-resolver-objects.html">13.6.3 EntityResolver Objects</A>
<b class="navlabel">Up:</b> <a class="sectref" href="markup.html" tppabs="http://www.python.org/doc/current/lib/markup.html">13. Structured Markup Processing</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-xml.sax.xmlreader.html" tppabs="http://www.python.org/doc/current/lib/module-xml.sax.xmlreader.html">13.8 xml.sax.xmlreader </A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -