'Where' clause in LINQ To XML not selecting anything

jeremynairobi

New Member
I am just trying to read some details from an XML file, part of which looks like this:\[code\]<appender name="FILE" class="applications.core.logging.CustomFileAppender"> <param name="File" value="http://stackoverflow.com/questions/10622767/C://Logs//File.log"/> <param name="MaxBackupIndex" value="http://stackoverflow.com/questions/10622767/5"/></appender><appender name="FILE" class="applications.core.logging.CustomFileAppender"> <param name="File" value="http://stackoverflow.com/questions/10622767/C://Logs//File2.log"/> <param name="MaxBackupIndex" value="http://stackoverflow.com/questions/10622767/17"/></appender><appender name="FILE" class="applications.core.logging.CustomFileAppender"> <param name="File" value="http://stackoverflow.com/questions/10622767/C://Logs//File3.log"/> <param name="MaxBackupIndex" value="http://stackoverflow.com/questions/10622767/98"/></appender>\[/code\]I have several of these 'appender' nodes in my XML file. The following code loops through each 'appender' node. Within each 'appender' I want to pick out the param node with name "File" and check if the value is equal to what I am looking for.\[code\]foreach (XElement node in XmlFile.Descendants("appender")) { IEnumerable<XElement> elements = from el in node.Elements("param") where el.Attribute("value").ToString().Equals("C:\\Logs\\File.log")) select el; foreach (XElement el in elements) { Console.WriteLine("Found it " + el.Name); // Now read value for MaxBackupIndex } }\[/code\]However my code is not printing anything out, so I think possibly the 'where' part of my LINQ query is incorrect, can anybody spot where I am going wrong?
 
Back
Top