public static void AddDataIfNotEmpty( this Dictionary<string, string> dictionary, XDocument document, string elementName) { var element = document.Root.Element(elementName); if (element != null) { dictionary.AddItemIfNotEmpty(elementName, element.Value); } }