TryGetAttribute

public static bool TryGetAttribute(this XElement element, XName attributeName, out XAttribute attribute)
{          
     attribute = element.Attribute(attributeName);
     return (attribute != null);
}
Example:
XAttribute cultureAttribute;
                if (element.TryGetAttribute("Culture", out cultureAttribute))
                {
//Do something with the attribute here
}

Description

Try/Get pattern for XDocument attributes

Details

Double click on the code to select all.

 

;