所以:
ReadXml("1.xml")
function ReadXml(url){
$.get(url, function(d){
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async = false
if( !xmlDoc.load(d) ){ alert(" 载入失败!")return false}
var objE = document.createElement("div")
objE.innerHTML = xmlDoc.xml
return objE
}
}
using System.Datausing System.Configuration
using System.Web
using System.Web.Security
using System.Web.UI
using System.Web.UI.WebControls
using System.Web.UI.WebControls.WebParts
using System.Web.UI.HtmlControls
using System.Xml
using System.Xml.XPathpublic partial class _Default : System.Web.UI.Page{public string[] x = new string[4]
protected void Page_Load(object sender, EventArgs e)
{ XmlDocument xmlDoc = new XmlDocument()
xmlDoc.Load(Server.MapPath("table.xml"))//你的xml文件
XmlNodeList xmlList = xmlDoc.SelectSingleNode("MapSheet").ChildNodes
foreach (XmlNode xmlNo in xmlList){//XmlNodeList xe = (XmlNodeList)xmlNo
XmlElement xe = (XmlElement)xmlNo{if (xe.Name == "TableName"){y[0] = xe.InnerText
} if (xe.Name == "DataSource"){y[1] = xe.InnerText
} if (xe.Name == "UserName"){y[2] = xe.InnerText
} if (xe.Name == "Password"){y[3] = xe.InnerText}}}TextBox1.Text=y[0]
TextBox2.Text = y[1]
TextBox3.Text = y[2]
}}该程序已经过测试,没有问题。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)