NuGet.XElementExtensions.GetOptionalElementValue C# (CSharp) Method

GetOptionalElementValue() public static method

public static GetOptionalElementValue ( this element, string localName, string namespaceName = null ) : string
element this
localName string
namespaceName string
return string
        public static string GetOptionalElementValue(this XContainer element, string localName, string namespaceName = null)
        {
            XElement child;
            if (String.IsNullOrEmpty(namespaceName))
            {
                child = element.ElementsNoNamespace(localName).FirstOrDefault();
            }
            else
            {
                child = element.Element(XName.Get(localName, namespaceName));
            }
            return child != null ? child.Value : null;
        }