xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Tyler" <tylersi...@hotmail.com>
Subject Traversing a DOM by name
Date Mon, 08 Jan 2001 17:31:33 GMT

Hi,

I been trying to work out if there is an easy to traverse a DOM by element 
name. For example if I know the particular Node I am on has a child element 
called "childelement" then I would like to move directly to it. The only two 
ways I can see of doing this are either:

1. Iterate through the children using getFirstChild and getnextSibling 
checking the node name as I go. This is unsatifactory as I it would be nice 
to go directly to it in a "more efficient" manner.

2. Use getElementsByTagName. Unfortunately this returns all the Nodes for 
the whole tree below the current element when I am only interested in the 
immediate children.

Is there an API kicking arounf that I haven't seen that lets me access 
elements by name just for immediate children. I know there are issues when 
more than one child exists with the name but in my case I know there will 
only ever be one.

Thanks

Simon
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


Mime
View raw message