Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XPath Distinct

Status
Not open for further replies.

MrMilton

Programmer
Feb 25, 2004
6
CA
I would like to return a list of nodes, but i need the list to be distinct.

This is my first attempt to find items that are distinct by "city";

nodes = xdoc.SelectNodes("//person/location[not(city=preceding-sibling::city)]/city")


<person id="001">
<location>
<address1>8858 King St</address1>
<address2></address2>
<address3></address3>
<postalcode>T5T 6Y6</postalcode>
<city>Edmonton</city>
<provstate>AB</provstate>
</location>
</person>

Any suggestions would be great!

Thanks,

Milton
 
You were almost there:
Code:
nodes = xdoc.SelectNodes("//person/location[not(city=preceding-sibling::*/city)]/city")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top