<?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.
Great explanation of how to use preceding-sibling to find unique elements! If you're working with containerized applications, RKE2 is an excellent tool to manage and test your environments locally, ensuring smooth handling of XML and XPath queries in isolated containers.
ReplyDelete