Re: how to use // starting from the root, when i am few steps under the root,

Subject: Re: how to use // starting from the root, when i am few steps under the root,
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 22 Aug 2000 08:41:40 +0100
Babu,

>        <applytemplates select="what to put here if i
>want to start from the root//ten"

If you start an XPath with '/', then it goes from the root.  If you want to
get all the 'ten' elements in the source, then the XPath you want is
'//ten'.  If you meant all the 'ten' elements from the 'root' element
(which is the document element in your case), then you can use '/root//ten'
(though this gives exactly the same effect as 'root' is the document element).

Generally you should try to avoid using '//' in your XPaths wherever
possible because it's very inefficient.  Give a step-by-step path to the
node you're interested in instead:

  /root/one/two/three/four/five/six/seven/eight/nine/ten

and don't forget that you can cut this down if you're already some way down
the tree (and an ancestor of the element you're interested in; for example,
if the current node is 'four', then you just have to do:

  five/six/seven/eight/nine/ten

you don't have to go all the way back to the root node and start again.

I hope that this helps,

Jeni

Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread