By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,060 Members | 1,878 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,060 IT Pros & Developers. It's quick & easy.

//b[1]//c gives different results if the first b is nested in anotherelement

P: n/a
<a>
<b>
<c/><c/>
</b>
<b>
<c/><c/><c/>
</b>
<b>
<c/>
</b>
</a>

Doing //b[1]//c on that yields two items. If, however, I put the
first <b></bwithin a <d></d>, I get five items. My question is...
why?

Here's what I mean by "put the first <b></bwithin a <d></d>":

<a>
<d>
<b>
<c/><c/>
</b>
</d>
<b>
<c/><c/><c/>
</b>
<b>
<c/>
</b>
</a>

Why does that return 5 items when the first only returns 2?
Sep 14 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
yawnmoth wrote:
<a>
<b>
<c/><c/>
</b>
<b>
<c/><c/><c/>
</b>
<b>
<c/>
</b>
</a>

Doing //b[1]//c on that yields two items. If, however, I put the
first <b></bwithin a <d></d>, I get five items. My question is...
why?

Here's what I mean by "put the first <b></bwithin a <d></d>":

<a>
<d>
<b>
<c/><c/>
</b>
</d>
<b>
<c/><c/><c/>
</b>
<b>
<c/>
</b>
</a>

Why does that return 5 items when the first only returns 2?

//b[1] means select all b that are the first b child of their parent.
If you want to select the first b descendant use
/descendant::b[1]

David
--
http://dpcarlisle.blogspot.com
Sep 14 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.