KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an XML that goes like this: <?xml version="1.0" encoding="utf-8" ?> <colors> <color index = "0">#FF0000</color> <color index = "1">#FF0200</color> <color index = "2">#FF0300</color> <color index = "3">#FF0500</color> [..] I'm trying to select a node by its index: XmlDocument ColorTable = new XmlDocument(); ColorTable.Load(HttpContext.Current.Server.MapPath("~/App_Data/ColorTable.xml")); int percentage = 2; string xpath = string.Format(@"//color[index={0}]", percentage.ToString()); //string xpath = string.Format(@"//color[index=""{0}""]", percentage.ToString()); //string xpath = string.Format(@"//color[index='{0}']", percentage.ToString()); var r = ColorTable.SelectSingleNode(xpath).Value; I tried also the commented versions, but it does not return any result. Any suggestion?
Tags (comma-separated)
Save Edits
Cancel