Title: Recommend xml.etree for XML processing
Type: behavior Stage: resolved
Components: Documentation, XML Versions: Python 3.2, Python 3.3, Python 2.7
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: docs@python Nosy List: ash, docs@python, eric.araujo, ezio.melotti, flox, petri.lehtinen, serhiy.storchaka, terry.reedy, tshepang
Priority: normal Keywords:

Created on 2011-10-27 10:05 by ash, last changed 2015-11-26 17:16 by serhiy.storchaka. This issue is now closed.

Messages (6)
msg146484 - (view) Author: Alexey Shamrin (ash) Date: 2011-10-27 10:05
There are many libraries in Python stdlib [1]


Tutorial mentions xml.dom and xml.sax. [2]

In my experience xml.etree is the best library to quickly load some xml and mess with it. It would be nice to recommend people xml.etree in the tutorial [2] and in the beginning of section 19, "Structured Markup Processing Tools". [1]

msg146494 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-10-27 15:44
It makes sense that SAX and DOM would be mentioned in the tutorial: SAX is similar to how HTMLParser works and is used in many languages; DOM is the official W3C API and is used in many languages, despite its ugliness.  ElementTree is not a very elegant API in my opinion, but the majority seems to disagree as it was included in Python 2.5, so I wouldn’t object to a one-line edition in the doc to suggest it.

If you’d like to work on a doc patch, here are guidelines:
msg146583 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-10-29 00:24
In the tutorial, "The xml.dom and xml.sax packages" should be expanded to "The xml.dom, xml.sax, and xml.etree packages". I suspect that the current line predates the addition of .etree.

We try to mostly not give opinion-based recommendations; the docs are for facts. Some people recommend using lxml instead of any of the above ;-).

"The documentation for the xml.dom and xml.sax packages are the definition of the Python bindings for the DOM and SAX interfaces."

could be followed by a factual sentence like "xml.etree provides an  third alternative."

Looking more: the intro to 19.6. xml.dom — The Document Object Model API nicely explains the difference between SAX and DOM processing as sequential versus random access. The intro to 19.13. xml.etree.ElementTree — The ElementTree XML API says nothing about how it compares to the others. Perhaps the sentence should be "xml.etree provides a tree-based interface different from xml.dom." (assuming this is a fact). Make your suggestion.
msg151050 - (view) Author: Tshepang Lekhonkhobe (tshepang) * Date: 2012-01-11 10:27
@Araujo bit offtopic, but which XML library have you found most elegant? Is it available in the stdlib?
msg151338 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-01-16 07:52
(I haven’t found an elegant XML lib, and have not yet needed to look for one as I touch very little XML.)
msg255057 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-11-21 15:03
The wording in the tutorial was changed in issue23891. Now ElementTree is mentioned on first place. In the "Structured Markup Processing Tools" section ElementTree is listed before other XML processing modules.

I think this issue can be closed now.
Date User Action Args
2015-11-26 17:16:39serhiy.storchakasetstatus: open -> closed
resolution: out of date
stage: resolved
2015-11-21 15:03:28serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg255057
2012-01-16 07:52:13eric.araujosetmessages: + msg151338
2012-01-11 10:27:23tshepangsetmessages: + msg151050
2012-01-11 10:26:12tshepangsetnosy: + tshepang
2011-10-29 00:24:18terry.reedysetnosy: + terry.reedy
messages: + msg146583
2011-10-27 15:46:25ezio.melottisetnosy: + ezio.melotti
2011-10-27 15:44:19eric.araujosetnosy: + eric.araujo
messages: + msg146494
2011-10-27 12:28:56petri.lehtinensetnosy: + petri.lehtinen
2011-10-27 10:16:49floxsetnosy: + flox
2011-10-27 10:16:37floxsettype: behavior
components: + XML
versions: + Python 2.7, Python 3.2, Python 3.3
2011-10-27 10:05:59ashcreate