Get specific xml lines with linq



I have an XML looking like this:



<data xmlns:xsi="http://ift.tt/ra1lAU">
<row>
<Alert>warning</Alert>
</row>
</data>


I wan't to get all the rows. In this case, the value that I wan't is "Alert".


This is as fare as I've got...



using (XmlReader reader = cmd.ExecuteXmlReader())
{
string xmlFile = "";
while (reader.Read())
{
xmlFile = reader.ReadOuterXml();
}
var xmlElement = XElement.Parse(xmlFile);
var result = xmlElement.Elements("data").Where(x => x.Value.Equals("row")).ToList();
}


I know something is wrong with my linq, but I'm quite new to linq and would like some help.


Thanks!


No comments:

Post a Comment