检索节点
来源:互联网 发布:淘宝美工店铺装修 编辑:程序博客网 时间:2024/05/17 06:47
文件夹6
text.xml:
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Table>
<EmployeeID>1</EmployeeID>
<EName>明*日</EName>
<ESex>男</ESex>
<EAge>25</EAge>
<EPlace>吉林省长春市</EPlace>
<EMoney>5000</EMoney>
</Table>
<Table>
<EmployeeID>2</EmployeeID>
<EName>张*三</EName>
<ESex>男</ESex>
<EAge>28</EAge>
<EPlace>吉林省长春市</EPlace>
<EMoney>3000</EMoney>
</Table>
<Table>
<EmployeeID>3</EmployeeID>
<EName>李*四</EName>
<ESex>女</ESex>
<EAge>23</EAge>
<EPlace>山西省长治市</EPlace>
<EMoney>3000</EMoney>
</Table>
<Table>
<EmployeeID>4</EmployeeID>
<EName>王*五</EName>
<ESex>女</ESex>
<EAge>26</EAge>
<EPlace>山西省长治市</EPlace>
<EMoney>2000</EMoney>
</Table>
</NewDataSet>
protected void Button1_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("test.xml"));加载xml
XmlNodeList nodes;
XmlElement root = doc.DocumentElement;
nodes = root.SelectNodes("descendant::Table[EName='" + TextBox1.Text.Trim() + "']");//descendant::双冒号//选择与XPath匹配的节点集合//获取此指定的节点集合下面进行遍历
//遍历指定节点集合,遍历输出
foreach (XmlNode node in nodes)
{
if (Label1.Text == "")
{
for (int i = 0; i <= node.ChildNodes.Count - 1; i++)
{
Label1.Text = Label1.Text + node.ChildNodes[i].InnerText + "<br>";
}
}
else
{
Label1.Text = "";
for (int i = 0; i <= node.ChildNodes.Count - 1; i++)
{
Label1.Text = Label1.Text + node.ChildNodes[i].InnerText + "<br>";
}
}
}
}
html:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_6_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div>
<table align="center" border="1" cellpadding="0" cellspacing="0" style="font-size: 9pt;
text-align: center">
<tr>
<td style="font-size: 9pt; color: #ffffff; background-color: #ff9933">
检索XML节点</td>
</tr>
<tr>
<td style="font-size: 9pt; vertical-align: middle; background-color: #ffffcc; text-align: left">
<table align="center">
<tr>
<td>
<table>
<tr>
<td style="height: 8px">
员工 ID:</td>
</tr>
<tr>
<td style="height: 8px">
员工姓名:</td>
</tr>
<tr>
<td style="height: 8px">
员工性别:</td>
</tr>
<tr>
<td style="height: 8px">
员工年龄:</td>
</tr>
<tr>
<td style="height: 8px">
员工籍贯:</td>
</tr>
<tr>
<td style="height: 8px">
员工薪水:</td>
</tr>
</table>
</td>
<td>
<asp:Label ID="Label1" runat="server" Font-Size="10pt" Width="77px"></asp:Label></td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="font-size: 9pt; background-color: #ffffcc">
请输入员工姓名:<asp:TextBox ID="TextBox1" runat="server" Width="73px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Font-Size="9pt" OnClick="Button1_Click" Text="检索节点" /></td>
</tr>
</table>
</div>
</div>
</form>
</body>
</html>
- 检索节点
- 检索xml节点
- TreeView检索节点所含关键字
- PRVF-0002 : 无法检索本地节点名
- PRVF-0002 : 无法检索本地节点名
- PRVF-0002 : 无法检索本地节点名
- easyui tree 检索树节点(3)
- 检索
- 检索
- 检索
- 检索
- 检索
- 在论坛中出现的比较难的sql问题:21(递归问题 检索某个节点下所有叶子节点)
- ASP.NET - 如何:筛选 SiteMapDataSource Web 服务器控件检索到的节点
- Oracle 12C报错信息:PRVF-0002: 无法检索本地节点名(Helloblock写作)
- 对 combotree 的改进, 包括展开到当前节点, 键盘操作树, 检索过滤
- 设平衡二叉排序树(AVL树) 的节点个数为n,则其平均检索长度为
- c实现按访问频度非递增有序的带头节点的双向链表检索关键字
- IIS HTTP 500错误
- jase--接口学习
- 两款js联动菜单
- 基于探测的Script (Event)SCOM 收集规则
- 第一次写的东西,为了积分,也欢迎大家访问
- 检索节点
- SQL函数总结
- C# 获取路径
- SQL Server子系统加载失败(The xx subsystem failed to load)错误的处理
- js动态添加标签(四)
- 关于Map和Reduce最大的并发数设置
- XMLDocument返回节点
- pthread_t definition
- 微软平台虚拟化管理平台开发研究