js能把留言写入xml数据库吗?
1个回答
展开全部
using
System;
using
System.Collections;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Web;
using
System.Web.SessionState;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.HtmlControls;
using
System.Xml;
private
XmlDocument
xmlDoc;
//load
xml
file
private
void
LoadXml()
{
xmlDoc=new
XmlDocument();
xmlDoc.Load(Server.MapPath("User.xml"));
}
//添加节点
private
void
AddElement()
{
LoadXml();
XmlNode
xmldocSelect=xmlDoc.SelectSingleNode("user");
XmlElement
el=xmlDoc.CreateElement("person");
//添加person节点
el.SetAttribute("name","风云");
//添加person节点的属性"name"
el.SetAttribute("sex","女");
//添加person节点的属性
"sex"
el.SetAttribute("age","25");
//添加person节点的属性
"age"
XmlElement
xesub1=xmlDoc.CreateElement("pass");
//添加person节点的里的节点
xesub1.InnerText="123";//设置文本节点
el.AppendChild(xesub1);
XmlElement
xesub2=xmlDoc.CreateElement("Address");
xesub2.InnerText="昆明";//设置文本节点
el.AppendChild(xesub2);
xmldocSelect.AppendChild(el);
xmlDoc.Save(Server.MapPath("user.xml"));
}
System;
using
System.Collections;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Web;
using
System.Web.SessionState;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.HtmlControls;
using
System.Xml;
private
XmlDocument
xmlDoc;
//load
xml
file
private
void
LoadXml()
{
xmlDoc=new
XmlDocument();
xmlDoc.Load(Server.MapPath("User.xml"));
}
//添加节点
private
void
AddElement()
{
LoadXml();
XmlNode
xmldocSelect=xmlDoc.SelectSingleNode("user");
XmlElement
el=xmlDoc.CreateElement("person");
//添加person节点
el.SetAttribute("name","风云");
//添加person节点的属性"name"
el.SetAttribute("sex","女");
//添加person节点的属性
"sex"
el.SetAttribute("age","25");
//添加person节点的属性
"age"
XmlElement
xesub1=xmlDoc.CreateElement("pass");
//添加person节点的里的节点
xesub1.InnerText="123";//设置文本节点
el.AppendChild(xesub1);
XmlElement
xesub2=xmlDoc.CreateElement("Address");
xesub2.InnerText="昆明";//设置文本节点
el.AppendChild(xesub2);
xmldocSelect.AppendChild(el);
xmlDoc.Save(Server.MapPath("user.xml"));
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询