• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help with xpath expression

 
C Wong
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would appreciate if someone could explain the following expression in plain English, if possible:
- select="//a[not(following::x=.)] | //x[not(preceding::a=.)] "
- select="//a[not(preceding::a=.)]" - (e.g. select unique value of a ??)
source: Whizlabs
 
Vivek Saxena
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can find your answer here.
VivekS.
 
C Wong
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks... but I still have doubts on the first part of the logic. - //a[not(following::x=.)].
Following Roseanne's suggestion, I interpret the logic as: Select all a elements which have x in its following axis and the node value of x does not equal to the node value of a.
My answer: 1 (from 1st B-set) 3 2 3 (from 2nd B-set). But the correct answer is 3 2 3 only!!
May be my interpretation is wrong!! Please help.
 
Vivek Saxena
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
XML File

I would say

Select all ‘a’ elements which have x in its following axis and the node value of ‘a’ node does not equal to the node value of ‘x’ in its following axis.

So My answer:
1st , 3rd and 4th node in second B-set. Which are basically 3,2,3
If I can be of further assistance, please let me know.
NOTE: For future I would suggest you to post full question including all the files. Just a suggestion.
Thanks
VivekS
 
C Wong
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vivek, I believe I almost get it. The reason that <a>1</a> from the first B-set is rejected is because there is <x>1</x> following in the 2nd B-set. In other words, "following" does not stop at the B-set, it stops at the end of file. Please confirm my understanding is correct. Thanks.
 
Vivek Saxena
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you are absolutely correct!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic