c# 载入xml文档,相对路径的问题!
String username2=this.txtName.Text.ToString();
String Email=this.txtEmail.Text.ToString();
String content=this.txtContent.Text.ToString();
String lastdate = System.DateTime.Now.ToString();
XmlDataDocument xmldoc = new XmlDataDocument();
xmldoc.Load(Server.MapPath("~/App_Data/guestbook.xml"));
XmlNode root = xmldoc.SelectSingleNode("Group");
XmlElement xe1 = xmldoc.CreateElement("Item");
xe1.SetAttribute("UserName",username2);
xe1.SetAttribute("UserEmail",Email);
xe1.SetAttribute("Content",content);
xe1.SetAttribute("SendTime",lastdate);
root.AppendChild(xe1);
xmldoc.Save(Server.MapPath("~/App_Data/guestbook.xml"));
请高手看一下,哪里出问题了,小弟初学!
出错信息:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Name cannot begin with the '2' character, hexadecimal value 0x32. Line 3, position 94.
出错行:Line 56: xmldoc.Load(Server.MapPath(dbPath));