This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: etree iterative find[text]
Type: enhancement Stage: resolved
Components: XML Versions: Python 3.2
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, Digitalxero, flox
Priority: normal Keywords: patch

Created on 2009-08-06 03:35 by Digitalxero, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit Digitalxero, 2009-08-06 03:35 patch file to include iter_find and iter_findtext Digitalxero, 2009-08-06 03:36 patch file to include iter_find and iter_findtext
Messages (4)
msg91348 - (view) Author: Dj Gilcrease (Digitalxero) Date: 2009-08-06 03:35
I recently converted a project from using a custom  implementation of 
xml.dom.minidom to using EelemntTree that comes with python2.5+ and 
found myself wishing for a find(tag_or_path) method that would do so iteratively instead of just on the current elements direct children. 
This is possible with the code as written;

looking_for = None
for el in etree.getiterator(tag_or_path):
    looking_for = el

I have to do this type of action so often in my code that I just decided 
to grab the python implementation of etree that came with py2.6 and 
include it with my app and patch in an iter_find method as the instant 
break for loop is just asking for maintenance issues down the road what 
I forget why I was breaking on the first loop no matter what.
msg91349 - (view) Author: Dj Gilcrease (Digitalxero) Date: 2009-08-06 03:36
second patch file
msg111544 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-25 13:09
@Digitalxero: could you provide an updated unit test file please.
msg146591 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2011-10-29 02:14
ElementTree 1.3 added the "iterfind" method to Python 2.7 and 3.2.
Date User Action Args
2022-04-11 14:56:51adminsetgithub: 50904
2011-10-29 02:14:39floxsetstatus: open -> closed
resolution: out of date
messages: + msg146591

stage: test needed -> resolved
2010-07-25 13:09:51BreamoreBoysetversions: - Python 2.7
nosy: + BreamoreBoy

messages: + msg111544

stage: test needed
2010-02-16 13:24:08floxsetpriority: normal
nosy: + flox
2009-08-06 03:36:13Digitalxerosetfiles: +

messages: + msg91349
2009-08-06 03:35:18Digitalxerocreate