On 07/05/14 17:56, Stefan Behnel wrote:
Alan Gauld, 07.05.2014 18:11:
and ElementTree (aka etree). The documenation gives examples of both. sax
is easiest and fastest for simple XML in big files ...
I wouldn't say that SAX qualifies as "easiest". Sure, if the task is
something like "count number of abc tags" or "find tag xyz and get an
attribute value from it", then SAX is relatively easy and also quite fast.
That's pretty much what I said. simple task, big file. sax is easy.
For anything else use etree.
BTW, ElementTree also has a SAX-like parsing mode, but comes with a simpler
interface and saner parser configuration defaults.
My experience was different. Etree is powerful but for simple
tasks I just found sax easier to grok. (And most of my XML parsing
is limited to simple extraction of a field or two.)
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor