Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XPath doubt.

 
Micheal Jacob
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sku != preceding::sku
Returns true if there is at least one child sku element with a string-value that does not equal that os one of the preceding sku elements.
not(sku = preceding::sku)
Return true if there is not a single child sku element with a string-value that equals that of one of the preceding sku elements.

In XML Quick Reference , they say these two are not equal. How ?

Micheal
 
Steven Broadbent
Ranch Hand
Posts: 400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ! and not do seem a little strange in xpath and need to be read carefully. It's one of the common gotchas.
Consider the following 2 xpaths:-

1) //author[ @age != "34" ]
2) //author[ not(@age = "34") ]
The first example selects all author element nodes whose age attributes' do not equal 34.
The second will select all authors that do not have an age attribute whose value is 34 OR who do not have an age attribute.
So an element like <author></author>
will be selected by xpath 2 but not by xpath 1.
You need to read the xpath carefully:-
1) select all author elements where the age attribute is not equal to 34.

2)all author elements which do not have an age attribute with the value 34.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic