XQuery while using distinct-values()

hasan0011

New Member
XML File \[code\]<Cities> <Place> <City n="New Delhi"></City> <City n="Chandigarh"></City> <City n="Mumbai"></City> </Place> <Place> <City n="New Delhi"></City> <City n="Chandigarh"></City> </Place> <Place> <City n="New Delhi"></City> <City n="Mumbai"></City> </Place></Cities>\[/code\]I am using following XQuery -\[code\]for $x in doc("sample")/Cities/Place/City order by $x/@n return distinct-values($x/@n)\[/code\]The result I am expecting is - \[code\]Chandigarh Mumbai New Delhi\[/code\]but getting - \[code\]Chandigarh Chandigarh Mumbai Mumbai New Delhi New Delhi New Delhi\[/code\]Please tell me where am I going wrong?
 
Back
Top