Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I was wondering if there is a way to index nodes inside the query string you use to get the path to the node you want as I need to get an attribute of a specific node but can't work out how to do this.

All the nodes are the same but I want to get the 5th one.

C#
if (DataDoc.SelectNodes("/SiteRep/DV/Location/Period/Rep/@T")[6] != null)
index^
I want to get the 5th Rep node but they are all begin with Rep so how can I index them inside the string. Thank you
Posted

1 solution

You're close, just put the index in the path:
C#
if (DataDoc.SelectNodes("/SiteRep/DV/Location/Period/Rep[5]/@T") != null)
 
Share this answer
 
Comments
Henry Hunt 6-Sep-13 12:01pm    
Does this work with attributes in the same way?
woopsydoozy 6-Sep-13 12:12pm    
well, no, because if your attribute names are duplicated inside a tag, you have invalid XML.
Menon Santosh 6-Sep-13 14:44pm    
my + 5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900