GeeCON Prague 2014*
The moose likes XML and Related Technologies and the fly likes Getting distinct Values from XML using XPath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Getting distinct Values from XML using XPath" Watch "Getting distinct Values from XML using XPath" New topic
Author

Getting distinct Values from XML using XPath

Udit Manektala
Ranch Hand

Joined: Sep 17, 2006
Posts: 30
So I need to retrieve distinct values for the Source Element in this XML.
I identified 2 ways:



1. A function called distinct-values. Gave an exception. Here's how i tried it:

2. I tried a method i took from
this website
link
Here;s how I tried to implement it:


The problem with the second method is that i need to look for the preceding sibling of the parent and not the preceding sibling of the SOURCE Element. And I cant find a function for finding the parent element.
Udit Manektala
Ranch Hand

Joined: Sep 17, 2006
Posts: 30
fixed it:

List lList1 = inputXML.selectNodes("/RESPONSE/RECORD[not( SOURCE/text()=preceding-sibling::RECORD/SOURCE/text())]/SOURCE/text() ");

Anyone know a better way ?

But still can't figure out what the Object Type of the thing is thats stored in the List.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting distinct Values from XML using XPath