<?xml version="1.0" encoding="UTF-8"?> <!--Sample XML file generated by XMLSpy v2008 sp1 (http://www.altova.com)--> <db:p> <db:ss> <db:tt> <db:a>123</db:a> <db:a>120</db:a> </db:tt> <db:tt> <db:a>123</db:a> <db:a>129</db:a> </db:tt> </db:ss> <db:ss> <db:tt> <db:a>345</db:a> <db:a>120</db:a> <db:a>123</db:a> <db:a>340</db:a> </db:tt> </db:ss> </db:p>
After some tries I come out with the following xpath expression.
/*:p/*:ss/*:tt/*:a[ not(. = ../preceding-sibling::*/*:a) and not(. = ../../preceding-sibling::*/*:tt/*:a)]
Here I use two preceding-sibling because <a> element is under <ss> and <tt> elements.