asp.ent操作xml在页面上显示节点标签内容
//引入命名空间
using System.Xml;
//加载xml文件
protected void Page_Load(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("LeaveWord.xml")); }
//显示绑定查询LeaveWord.xml信息
protected void BtnSelect_Click(object sender, EventArgs e)
{
this.lblcondition.Text = "";//清空标签中的内容
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("LeaveWord.xml"));
XmlNodeList nodes;
XmlElement root = doc.DocumentElement;
nodes = root.SelectNodes("descendant::LW[ID='" + TxtID.Text.Trim() + "']");
foreach (XmlNode node in nodes)
{
if (lblcondition.Text == "")
{
for (int i = 0; i <= node.ChildNodes.Count - 1; i++)
{
lblcondition.Text = lblcondition.Text + node.ChildNodes[i].InnerText + "<br><br>";
//this.GridView1.Rows[i].Cells[i].Controls[0].ToString()=node.ChildNodes[i].InnerText;
}
}
else
{
lblcondition.Text = "";
for (int i = 0; i <= node.ChildNodes.Count - 1; i++)
{
lblcondition.Text = lblcondition.Text + node.ChildNodes[i].InnerText + "<br>";
}
}
}
}
//引入命名空间
using System.Xml;
//加载xml文件
protected void Page_Load(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("LeaveWord.xml")); }
//显示绑定查询LeaveWord.xml信息
protected void BtnSelect_Click(object sender, EventArgs e)
{
this.lblcondition.Text = "";//清空标签中的内容
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("LeaveWord.xml"));
XmlNodeList nodes;
XmlElement root = doc.DocumentElement;
nodes = root.SelectNodes("descendant::LW[ID='" + TxtID.Text.Trim() + "']");
foreach (XmlNode node in nodes)
{
if (lblcondition.Text == "")
{
for (int i = 0; i <= node.ChildNodes.Count - 1; i++)
{
lblcondition.Text = lblcondition.Text + node.ChildNodes[i].InnerText + "<br><br>";
//this.GridView1.Rows[i].Cells[i].Controls[0].ToString()=node.ChildNodes[i].InnerText;
}
}
else
{
lblcondition.Text = "";
for (int i = 0; i <= node.ChildNodes.Count - 1; i++)
{
lblcondition.Text = lblcondition.Text + node.ChildNodes[i].InnerText + "<br>";
}
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货