/// NOT REFERENCED. //public static XmlDocument ToXmlDocument(this IDictionary dictionary, string outerNodeName = null) //{ // if (dictionary == null) // throw new ArgumentNullException("dictionary"); // var result = XmlExtensions.CreateNewDocument(outerNodeName ?? "Element"); // dictionary.AddChildElements(result, result.FirstChild); // return result; //} public static XmlNode AddChildElements(this IDictionary dictionary, XmlDocument document, XmlNode nodeToAppendTo) { if (dictionary == null) { throw new ArgumentNullException("dictionary"); } if (document == null) { throw new ArgumentNullException("document"); } if (nodeToAppendTo == null) { throw new ArgumentNullException("nodeToAppendTo"); } foreach (var key in dictionary.Keys) { if (key == null) { continue; } var value = dictionary[key]; if (value == null) { continue; } var valueDictionary = value as IDictionary; if (valueDictionary == null) { document.AddChildElement(nodeToAppendTo, key.ToString(), value.ToString()); } else { var newElement = document.AddChildElement(nodeToAppendTo, key.ToString()); var newChildElements = ((IDictionary)value).AddChildElements(document, newElement); } } return(nodeToAppendTo); }