Reputation: 786
Here's my XML:
<c01>
<did>
<unittitle>Title</unittitle>
</did>
<c02>
<did>
<unittitle>Title</unittitle>
</did>
</co2>
<c02>
<did>
<unittitle>Title</unittitle>
</did>
</co2>
<c02>
<did>
<unittitle>Title</unittitle>
</did>
</co2>
</c01>
The active node is <did>
as I'm working on a template. From any c02/did
what XPATH do I use to select only the first c02
child of c01
?
Upvotes: 0
Views: 94
Reputation: 786
The answer is:
<xsl:if test=".. is ../../c02[1]">
Thanks, Martin and Wendell.
Upvotes: 0
Reputation: 33658
Try
../../c02[1]
This expression walks up two nodes from c02/did
to c01
and then selects the first c02
child.
Upvotes: 1