Subject: Re: XPath expression for finding out the depth of a given node?
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Sun, 17 Nov 2002 12:10:13 -0800
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sunday 17 November 2002 10:10, Andreas Schildbach wrote:
> Is there a XPath expression for finding out the depth of a given node (or
> just the context node) in the document?
Well, XPath has a count() function, and it also has the ancestor:: axis, and
the '*' pattern to match any element. Put it all together, and you get
count(ancestor::*). That should pretty much do it. If you want a 1- based
count instead of a 0- count, use count(ancestor-or-self::*).
- --
Peter Davis
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE91/elhDAgUT1yirARAlNFAJ4y3yfmm4CR0kc+jz2SEXiZEVMK3ACdGOA4
GHm1DmcVfeBBq2X76Y/ocTQ=
=U9Pq
-----END PGP SIGNATURE-----
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|