You should take advantage of the Attributes
collection (represented by XmlAttributeCollection
) which is a part of your XmlNode
:
var alt = nodds.Attributes["alt"].Value;
var src = nodds.Attributes["src"].Value;
To make it error-proof you could extend it to something like this:
string altValue;
var altAttribute = nodds.Attributes["alt"];
if(altAttribute != null)
{
altValue = nodds.Attributes["alt"].Value;
}