js能把留言写入xml数据库吗?
我想用JS结合html做网站,别人写的留言,可以存储到xml数据库吗?可以实现吗?还是要结合php来实现呢?我的意思是说用xml做数据库...
我想用JS结合html做网站,别人写的留言,可以存储到xml数据库吗?可以实现吗?还是要结合php来实现呢?我的意思是说用xml做数据库
展开
2个回答
2013-07-17
展开全部
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"));
}
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"));
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-17
展开全部
<script language="javascript">
function saveas()
{
var a = new ActiveXObject("Msxml2.Domdocument");
a.async=false;
a.load("d:\\11.xml");
show.innerHTML=a.documentElement.xml;
b=a.createElement("newNode");
b.text="new Value";
a.documentElement.appendChild(b);
var winSave = window.open();
winSave.document.open ("text/html","gb2312");
winSave.document.write (a.xml);
winSave.document.execCommand ("SaveAs",true,"c:\\11.xml");
winSave.close();
}
</script>
function saveas()
{
var a = new ActiveXObject("Msxml2.Domdocument");
a.async=false;
a.load("d:\\11.xml");
show.innerHTML=a.documentElement.xml;
b=a.createElement("newNode");
b.text="new Value";
a.documentElement.appendChild(b);
var winSave = window.open();
winSave.document.open ("text/html","gb2312");
winSave.document.write (a.xml);
winSave.document.execCommand ("SaveAs",true,"c:\\11.xml");
winSave.close();
}
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询