• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XPath

 
Anup Batra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • 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
 
Vasudha Deepak
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • 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
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • 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
 
Samba Siva Rao Potla
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic