Selectnodes only get the first node



I have an XML file looking like this:



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


When I use the code below I only get the "Alert"-node. But I wan't "Alert2" as well (and so on...). What am I missing here?



using (XmlReader reader = cmd.ExecuteXmlReader())
{
string xmlFile = "";
while (reader.Read())
{
xmlFile = reader.ReadOuterXml();
}

var doc = new XmlDocument();
doc.LoadXml(xmlFile);
var nodes = doc.SelectNodes("data/row");

if (nodes == null) return columns;
var i = 0;
foreach (XmlNode node in nodes)
{
var column = node.ChildNodes[i].Name;
columns.Add(column);
i++;
}
return columns;
}

No comments:

Post a Comment