Confusion over etree.ElementTree.Element.getiterator
Ben Sizer
kylotan at gmail.com
Sat Jul 3 18:12:04 EDT 2010
It seems that getiterator isn't returning the tags I ask for.
>>> tree = parse('gdlibs.html')
>>> root = tree.getroot()
>>> for el in root.getiterator():
... print el
[much output snipped]
<Element {http://www.w3.org/1999/xhtml}a at d871e8>
<Element {http://www.w3.org/1999/xhtml}a at d87288>
<Element {http://www.w3.org/1999/xhtml}script at d87300>
<Element {http://www.w3.org/1999/xhtml}script at d87378>
>>> it = root.getiterator('script')
>>> all_scripts = list(it)
>>> print len(all_scripts)
0
I would have expected at least 2 script tags to be found, considering
iterating over the whole lot found at least 2 at the end there.
What am I doing wrong?
>>> import sys
>>> print sys.version
2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]
I will upgrade to 2.6.5 ASAP, but I don't see anything in the
changelog that implies a bug that has been fixed here.
--
Ben Sizer
More information about the Python-list
mailing list