• Post Reply Bookmark Topic Watch Topic
  • New Topic
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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Need help with xpath expression

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can find your answer here.
VivekS.
 
C Wong
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you are absolutely correct!
 
A magnificient life is loaded with tough challenges. En garde tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic