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