posted 21 years ago
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.
"....bigmouth strikes again, and I've got no right to take my place with the human race...."<p>SCJP 1.4