Getting a DOM element's children by type (STUPID)

Tom Anderson twic at urchin.earth.li
Wed Jun 8 19:24:35 EDT 2005


Hi,

If i get myself a DOM tree using xml.dom.minidom (or full-fat xml.dom, i 
don't mind), is there an easy way to ask a element for its child elements 
of a particular type? By 'type' i mean 'having a certain tag'.

This strikes me as a rather common thing to want to do, but i can't see a 
method for it; it seems i have to go through elem.childNodes myself, 
fishing out the ones i want. Or rather, to write exactly the same 
three-line helper function that millions of other people must have written 
to do this. Am i missing something blindingly obvious? I'm happy to RTFM 
here, but would appreciate a pointer to the appropriate such manual, since 
the docs i have to hand are somewhat unenlightening.

Thanks,
tom

-- 
Just because Congresspeople do it, doesn't mean it's right. -- Ian York



More information about the Python-list mailing list