Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > //b[1]//c gives different results if the first b is nested in anotherelement

Reply
Thread Tools

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

 
 
yawnmoth
Guest
Posts: n/a
 
      09-14-2008
<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></b> within a <d></d>, I get five items. My question is...
why?

Here's what I mean by "put the first <b></b> within 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?
 
Reply With Quote
 
 
 
 
David Carlisle
Guest
Posts: n/a
 
      09-14-2008
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></b> within a <d></d>, I get five items. My question is...
> why?
>
> Here's what I mean by "put the first <b></b> within 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
scanf gives different results on short and long overflow myx C Programming 2 05-26-2009 06:22 PM
WepApp - DateTime.Now.Date.ToString() gives different results =?Utf-8?B?RmFlc3NsZXIgR2lsbGVz?= ASP .Net 5 06-08-2007 11:10 AM
hash() yields different results for different platforms Qiangning Hong Python 12 07-12-2006 02:08 PM
Different defrag utilities, different results! cygnian@msn.com Computer Support 6 05-12-2005 06:25 PM
C extension=> pow(2,1) gives DIFFERENT answers in different parts of C extension!?!?! Any ideas why? Christian Seberino Python 3 02-05-2004 04:36 AM



Advertisments