Is it possible in XPATH to select a list of unique element from a node where there are many of the same?
<Deserts>
<Desert Code="C1">Popsicle<Desert>
<Desert Code="H2">Ice Cream<Desert>
<Desert Code="C1">Popsicle<Desert>
<Desert Code="T1">Cheese Cake<Desert>
</Deserts>
In this example I want the resulting list to have only 3 nodes (Popsicle / Ice Cream / Cheese Cake).
How can I select such a list with Xpath?
Try the following xpath:
/Deserts/Desert[not(@Code=preceding-sibling::Desert/@Code)]
It will return distinct deserts by checking the Desert Code attribute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With