• 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

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all!
Can any one tell me the differenec between these
� para[@type="warning"][5] selects the fifth para child of the context node that has a type attribute with value warning
� para[5][@type="warning"] selects the fifth para child of the context node if that child has a type attribute with value warning
Thanks in Advance,
Anup Batra
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

� para[@type="warning"][5] selects the fifth para child of the context node that has a type attribute with value warning


This selects the fifth child element of the context node,if the context node has an attribute type with value="warning", whereas the XPath expression shown below selects the fifth child element of the context node,if the child has an attribute type with value="warning".


� para[5][@type="warning"] selects the fifth para child of the context node if that child has a type attribute with value warning


I hope this helps.
Vasudha
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anybody know whether [5] in these examples is a predicate?
The book says - "Predicates that evaluate to numbers are true if they're equal to the position of the context node, false otherwise". So, syntactically [5] can be a predicate.
But can we have two predicates together like para[@type="warning"][5]?
Thanks,
Dan
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Does this mean First predicate would be apllied on the Conext Node and Second would applied on Selected Node set. Location Step can Contains maximum two Predicates.
Please validate me

Regards,
Rao
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good Day,
The XPath specification says that a location step can have - "zero or more predicates, which use arbitrary expressions to further refine the set of nodes selected by the location step."
It also says that the predicate [5] is equivalent to [position()=5].
Cheers,
Dan
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic