programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Tim Cooke
• Paul Clapham
• Devaka Cooray
• Bear Bibeault
Sheriffs:
• Junilu Lacar
• Knute Snortum
• Liutauras Vilda
Saloon Keepers:
• Ron McLeod
• Stephan van Hulst
• Tim Moores
• Tim Holloway
• Piet Souris
Bartenders:
• salvin francis
• Carey Brown
• Frits Walraven

Need help with xpath expression

Greenhorn
Posts: 18
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

Ranch Hand
Posts: 58
VivekS.

C Wong
Greenhorn
Posts: 18
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!!

Vivek Saxena
Ranch Hand
Posts: 58
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.

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
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
Yes you are absolutely correct!

 The glass is neither half full or half empty. It is too big. But this tiny ad is just right: Two software engineers solve most of the world's problems in one K&R sized book https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton