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);
        }
Exemplo n.º 2
0
        public static string GetOptionalElementValue(this XContainer element, string localName, string namespaceName = null)
        {
            XElement element2 = !string.IsNullOrEmpty(namespaceName) ? element.Element(XName.Get(localName, namespaceName)) : element.ElementsNoNamespace(localName).FirstOrDefault <XElement>();

            return(element2?.Value);
        }