asp.net - XmlDataSource.XPath, select distinct rows -


i need select distinct rows xml data 2 column primary key being col1 , col2:

<data>   <col1>x</col1>   <col2>x</col2>   <col3>x</col3> </data> <data>   <col1>x</col1>   <col2>x</col2>   <col3>x</col3> </data> 

i came across "preceding-sibling" function not find tutorial. how select distinct col1 , col2? thank help.

you can't group complex keys (other 1 node value) xpath 1.0 expression.

you group 1 key , iterating host language on xpath expression result:

/*/data[not(col1 = ../preceding-sibling::data/col1)] 

and after registering $col1 variable (or replacing value in expression) col1, use this:

/*/data[col1 = $col1][not(col2 = ../preceding-sibling::data[col1 = $col1]/col2)] 

Comments