xml问题
OpenFileDialog of = new OpenFileDialog();of.Filter = "mp3 files (*.mp3)|*.mp3";
if (of.ShowDialog() == DialogResult.OK)
{
txtMusic.Text = of.FileName.ToString();
}
我用这段代码浏览下文件
XmlDocument xmldoc = new XmlDocument();
XmlElement xmlelem = xmldoc.CreateElement("", "Discuss_root", "");
xmldoc.AppendChild(xmlelem);
XmlNode root = xmldoc.SelectSingleNode("Discuss_root");
XmlElement xe = xmldoc.CreateElement("Discuss_Set");
root.AppendChild(xe);
XmlElement xeTitle = xmldoc.CreateElement("Discuss_Title");
xeTitle.InnerText = txttitle.Text.ToString();
xe.AppendChild(xeTitle);
XmlElement xeMusic = xmldoc.CreateElement("Discuss_Music");
xeMusic.InnerText = txtMusic.Text.ToString();
xe.AppendChild(xeMusic);
xmldoc.Save("Discuss.xml");
this.DialogResult = DialogResult.OK;
this.Close();
然后这段保存XML的代码可以正确执行,但是xml文件并没有被修改并保存