Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting distinct Values from XML using XPath

 
Udit Manektala
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic