Re: method to return only the specificied child elements?

>: how come there are no method that allows an Element to get only the
child elements specified by their tag name?

The DOM doesn't provide every possible convenience function. It provides
the essentials, and some conveniences which have specific historical or
efficiency justifications. If we don't provide a function, write your own
support routine that does.

In this case: You could write an appropriate filter to test the "tag name",
and plug it into a NodeIterator or TreeWalker. But it may be easier and
possibly more efficient to write a
get-next-sibling-and-test-node-name-and-type loop. Given that it's so easy
to do either way, there's really no need for the DOM to supply a canned
version.

______________________________________
Joe Kesselman  / IBM Research

Received on Tuesday, 22 January 2002 08:52:34 UTC