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.
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 @@
In addition, a custom :class:`TreeBuilder` object can provide the
- following method:
+ following methods:
.. method:: doctype(name, pubid, system)
@@ -1096,6 +1096,23 @@
.. 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 @@
: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::