Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

XPath doubt.

 
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
 
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.
 
Eat that pie! EAT IT! Now read this tiny ad. READ IT!
ScroogeXHTML 8.7 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/730700/ScroogeXHTML-RTF-HTML-XHTML-converter
    Bookmark Topic Watch Topic
  • New Topic