惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threat Research - Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Vulnerabilities – Threatpost
GbyAI
GbyAI
P
Proofpoint News Feed
L
LINUX DO - 热门话题
P
Palo Alto Networks Blog
A
About on SuperTechFans
T
Tenable Blog
M
MIT News - Artificial intelligence
IT之家
IT之家
I
Intezer
D
DataBreaches.Net
爱范儿
爱范儿
T
Threatpost
C
CERT Recently Published Vulnerability Notes
云风的 BLOG
云风的 BLOG
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
K
Kaspersky official blog
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Y
Y Combinator Blog
Cyberwarzone
Cyberwarzone
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Darknet – Hacking Tools, Hacker News & Cyber Security
H
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
Spread Privacy
Spread Privacy
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
AWS News Blog
AWS News Blog
博客园 - 聂微东
C
Check Point Blog
S
Securelist
有赞技术团队
有赞技术团队
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
D
Docker
G
GRAHAM CLULEY
T
The Exploit Database - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tailwind CSS Blog
L
Lohrmann on Cybersecurity
G
Google Developers Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog

博客园 - suny2006

XmlDocument 操作xml文档 - suny2006 - 博客园 使用正则表达式 Eclipse3.2 中 Java Web(Jsp) 开发环境的搭建之 Lomboz+Tomcat 如何在asp.net中关闭B页面时,自动刷新A页面? - suny2006 - 博客园 Asp.Net防止刷新重复提交数据小记 Asp.Net防止刷新重复提交数据小记 如何使用变量给数据源控件参数赋值、如何动态增减数据源控件参数并支持分页 sql注入 下载www.youtube.com网站上视频的方法…… 使用 ADO.NET 访问 Oracle 9i 存储过程 ASP.NET调用oracle存储过程实现快速分页 关于一个网站实现简体和繁体的解决方案 vs2005比2003有什么本质性的变化?(转载) ASP.NET页面信息传递方法 试验通过就是牛 ---- 据说是世界编程大赛第一名写的程序 - suny2006 CODES 常用。NET相关网站 从ASP.NET数据库某字段为空时的处理所衍生出来的思考 一步一步学习ObjectDataSource控件--自定义分页排序
关于xml的模糊查询问题 - suny2006 - 博客园
suny2006 · 2006-12-16 · via 博客园 - suny2006

XML文件:
<Persons>
<Person id="1">
<Name>李一</Name>
<Sex>男</Sex>
</Person>
<Person id="2">
<Name>李二</Name>
<Sex>女</Sex>
</Person>
<Person id="3">
<Name>李三</Name>
<Sex>男</Sex>
</Person>
<Person id="4">
<Name>陈四</Name>
<Sex>男</Sex>
</Person>
<Person id="5">
<Name>李四</Name>
<Sex>女</Sex>
</Person>
</Persons>

现在,我希望针对“姓名”做一个模糊查询,在用户输入:“李”的时候,将姓李的资料全部显示出来,请高手帮忙指点,最好有源代码,谢谢了!

解决方法一:System.Xml.XmlDocument x = new System.Xml.XmlDocument();
x.Load(Server.MapPath("x1.xml"));
System.Xml.XmlNodeList nodes = x.SelectNodes("//Name");
foreach(System.Xml.XmlNode y in nodes)
{
if(y.InnerText.IndexOf("李") >-1)
Response.Write(y.InnerText);
}
解决方法2:System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

doc.Load("file:///d:/test.xml");

foreach (System.Xml.XmlNode n in doc.DocumentElement.SelectNodes("Person[contains(Name,'李')]"))
{
 MessageBox.Show(n.InnerXml);
}

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=131759