You can create a method like this:
public static string GetText(XmlNode xn, string attrName)
{
var attr = xn.Attributes[attrName];
if (attr == null). // Also check whether the attribute does not exist at all
return string.Empty;
var temp = attr.Value;
if (temp == null)
return string.Empty;
return temp;
}
And call it like this:
txtbxName.Text = GetText(xn, "name");