public static XmlDocument ToXmlDocument(this string str, string rootName = "") { if (!str.IsEmpty()) { if (!string.IsNullOrEmpty(rootName)) { var doc = new XmlDocument(); var root = XMLUtil.AddNode(doc.DocumentElement, rootName); root.SetValue(str); return(doc); } else { return(XMLUtil.LoadXml(str)); } } return(null); }