Re: Detecting positional elements

NOTE: These methods are only valid if the document is locked from
modification while you are doing the traversal.

To determine the depth of a node in the tree you can traverse the nodes
returned by getParentNode() until the method returns null and count how many
ancestors the node has.

To determine the ordinal position of a node within its siblings you can do
the same thing but call getPreviousSibling() instead of getParentNode().
You may find the result more meaningful if you only count nodes that are
elements.

Steve Oldmeadow
Justice Systems Technologies


-----Original Message-----
From: Wolfgang Belau <Wolfgang.Belau@ri.dasa.de>
To: www-dom@w3.org <www-dom@w3.org>
Date: Tuesday, 13 April 1999 4:07
Subject: Detecting positional elements


>Is there a way of detecting the positional location of a specific
>element?
>
>Such a feature would be of interest for certain applications, where one
>likes to position certain elements in relation to the position of other
>elements.
>
>
>best regards,
>
>
>Wolfgang Belau
>
>--------------------------------------------------------------------------
>Wolfgang Belau Phone:  +49 421 539 4519
>DaimlerChrysler Aerospace AG Fax:    +49 421 539 4529
>Space Infrastructure Division (RIO61) E-mail: Wolfgang.Belau@ri.dasa.de
>Huenefeld Str. 1-5
>P.O.Box 28 61 56
>D-28199 Bremen, GERMANY
>--------------------------------------------------------------------------
>

Received on Tuesday, 13 April 1999 04:37:41 UTC