• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting distinct Values from XML using XPath

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic