views:

184

answers:

2

I want to print only unique values from a dataset into the list component, avoiding duplicate values. How do I do it ? Please help.

A: 

Try something like the following when you are selecting nodes in you datasource using X-Path.

/root/*[not(text() = preceding-sibling::*/text())]

It will select unique nodes for a XML structure like bellow.

<root>
      <Node1>Data1</Node1>
      <Node2>Data2</Node2>
      <Node1>Data1</Node1>
      <Node2>Data2</Node2>
      <Node3>Data3</Node3>
</root>
Gordon
I am using XML as the data source.
payal
I dont want unique nodes, I want unique values from same nodes. For eg. <Product>Prod1</Product> <Product>Prod1</Product> <Product>Prod2</Product> <Product>Prod2</Product> ]Should return Prod1 and Prod2 only once, even though they appear twice in the xml data source.
payal
+1  A: 

You can group on that value, in your case the Product, grouping will eliminate duplicates.

NOTE: the data should be sorted for grouping to work

medopal