summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2019-05-01 19:49:58 (GMT)
committerGitHub <noreply@github.com>2019-05-01 19:49:58 (GMT)
commitdde3eebdaa8d2c51971ca704d53af7cbcda8bb34 (patch)
treeff16947548ec92506e63f98bbf79d9ad7af296a8 /Doc/library
parent43851a202cabce1e6be699e7177735c778b6697e (diff)
downloadcpython-dde3eebdaa8d2c51971ca704d53af7cbcda8bb34.zip
cpython-dde3eebdaa8d2c51971ca704d53af7cbcda8bb34.tar.gz
cpython-dde3eebdaa8d2c51971ca704d53af7cbcda8bb34.tar.bz2
bpo-36676: Namespace prefix aware parsing support for the ET.XMLParser target (GH-12885)
* bpo-36676: Implement namespace prefix aware parsing support for the XMLParser target in ElementTree.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/xml.etree.elementtree.rst22
1 files changed, 20 insertions, 2 deletions
diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst
index c9e04c2..66090af 100644
--- a/Doc/library/xml.etree.elementtree.rst
+++ b/Doc/library/xml.etree.elementtree.rst
@@ -1086,7 +1086,7 @@ TreeBuilder Objects
In addition, a custom :class:`TreeBuilder` object can provide the
- following method:
+ following methods:
.. method:: doctype(name, pubid, system)
@@ -1096,6 +1096,23 @@ TreeBuilder Objects
.. versionadded:: 3.2
+ .. method:: start_ns(prefix, uri)
+
+ Is called whenever the parser encounters a new namespace declaration,
+ before the ``start()`` callback for the opening element that defines it.
+ *prefix* is ``''`` for the default namespace and the declared
+ namespace prefix name otherwise. *uri* is the namespace URI.
+
+ .. versionadded:: 3.8
+
+ .. method:: end_ns(prefix)
+
+ Is called after the ``end()`` callback of an element that declared
+ a namespace prefix mapping, with the name of the *prefix* that went
+ out of scope.
+
+ .. versionadded:: 3.8
+
.. _elementtree-xmlparser-objects:
@@ -1131,7 +1148,8 @@ XMLParser Objects
:meth:`XMLParser.feed` calls *target*\'s ``start(tag, attrs_dict)`` method
for each opening tag, its ``end(tag)`` method for each closing tag, and data
- is processed by method ``data(data)``. :meth:`XMLParser.close` calls
+ is processed by method ``data(data)``. For further supported callback
+ methods, see the :class:`TreeBuilder` class. :meth:`XMLParser.close` calls
*target*\'s method ``close()``. :class:`XMLParser` can be used not only for
building a tree structure. This is an example of counting the maximum depth
of an XML file::