• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

xPath question

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, does anyone know what the following xPath does?

//select[not(//label/@for=./@id)]

Also, what does /@for means here?

Thanks.
 
Payam Fard
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, what is the difference between //label[@for=...] and //label/@for=...?

Thanks.
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Payam Fard wrote://select[not(//label/@for=./@id)]



It finds all of the elements whose name is "select", which are not in any namespace, and for which the expression in [...] can be coerced to "true".

The expression inside [...] is called a "predicate" and it should be an expression which can be coerced to boolean, as this one is. Ignoring the not() function, the expression is of the form A=B. Note that either side (or both) of such an expression can be a nodeset, and two nodesets are equal if any node in A is equal to any node in B. (At least that's how it is in XPath 1.0; it might be different in XPath 2.0, but that's beyond the scope of what I know.)

Does that get you started? The expression itself looks like somebody made it up as a joke, though.
 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Payam Fard wrote:Also, what is the difference between //label[@for=...] and //label/@for=...?



The first selects all "label" elements for which the following predicate is true. The second isn't an XPath expression, at least I don't think it is.
 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Payam Fard wrote:Also, what does /@for means here?



It doesn't really mean anything, or rather the question is kind of meaningless because you've chopped a random segment out of an expression. However "label/@for" means "the for attribute of a label element".
reply
    Bookmark Topic Watch Topic
  • New Topic