XmlElement elmRoot = xdoc.CreateElement("Media"); foreach (FileInfo i in opt.checkedListBox1.Items) { XmlElement elmfile = xdoc.CreateElement("File"); XmlElement elmtitle = xdoc.CreateElement("Title"); XmlText txt_title = xdoc.CreateTextNode(i.Name.ToString()); elmRoot.AppendChild(elmfile); elmRoot.LastChild.AppendChild(elmtitle); elmRoot.LastChild.LastChild.AppendChild(txt_title); XmlElement elm_file_path = xdoc.CreateElement("Full-Path"); XmlText txt_file_path = xdoc.CreateTextNode(i.FullName.ToString()); elmRoot.LastChild.AppendChild(elm_file_path); elmRoot.LastChild.LastChild.AppendChild(txt_file_path); XmlElement elmext = xdoc.CreateElement("Extension"); XmlText txt_ext = xdoc.CreateTextNode(i.Extension.ToString()); elmRoot.LastChild.AppendChild(elmext); elmRoot.LastChild.LastChild.AppendChild(txt_ext); } xdoc.Save("treeviewxml.xml");
Invalid XML document, The document does not have a root element..
xmldoc.AppendChild(elmRoot);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)