If the attribute "name" is not in the node, I assumed the following would work:
if (objTmplt.Attributes.GetNamedItem("name").Value != null)
styleName = objTmplt.Attributes[Atrb.Name].Value;
However, it throws an unhandled exception. This has me backed into a corner where trying to prevent a null unhandled exception causes an exception. I worked with both methods of Attributes.GetNamdeItem and Attributes["name"] with the same effect.
I want to avoid wrapping hundreds of lines with try-catch or iteration blocks. In VB.Net the Attributes.GetNamedItem does not throw an error if the attribute is missing. It simply creates an empty string. C# seems to have a different result.
It is late and I am sure I am just missing something.