[thelist] RE: XPath Parent Position

Tim Kuhn (temp) Tim.Kuhn at gettyimages.com
Fri Nov 7 13:21:26 CST 2003


Ah, my chance to redeem myself after the bogus answer I gave you earlier in the week. 

<xsl:template match="top">
		<xsl:value-of select="//b[@id='fowl']/parent::*/@id" />
	</xsl:template>

Will return "bird" from the following xml. Modify for your own needs.
The term for this is the Parent Axis if you want to search for more information. 

<top>
	<a name="bob" id="dog">
		<b id="tree">b</b>
		<b id="bush">c</b>
		<b id="grass">d</b>
	</a>
	<aa name="tom" id="bird">
		<b id="fish">bb</b>
		<b id="fowl">cc</b>
		<b id="farm">dd</b>
	</aa>
</top>  

Free tip for Friday!
<tip type="xpath">
	Here is a great xpath cheat sheet
	http://www.deepx.com/resources/quickref/XPath-1.0.pdf
</tip>

-----Original Message-----


This is more a question for the sake of curiousity than anything I need 
Right Now. I'm trying to determine (and output), while working in a given 
node, the position of the parent node. What seems to be working is:

<xsl:value-of select="count(../preceding-sibling::*) + 1"/>




=======================================================
This email and its contents are confidential. If you
are not the intended recipient, please do not disclose
or use the information within this email or its
attachments. If you have received this email in error,
please delete it immediately. Thank you.
=======================================================


More information about the thelist mailing list