xml 查询问题
<users>
<user>
<userName> aaaa </userName>
<userPassword> bbbb </userPassword>
</user>
<user>
<userName> ssss </userName>
<userPassword> dddd </userPassword>
</user>
</users>
这是一个xml文档里的内容,我想用一个textbox输入字符串,对xml里的userName进行查询判断是否为输入的字符串,该如何来查询?
谢谢各位大侠帮忙
------解决方案--------------------XmlDocument doc = new XmlDocument();
doc.load( "your.xml ")
XmlNodeList nodeList = doc.GetElementsByTagName( "users ");
string name = " ";
foreach (XmlNode node in nodeList)
{
XmlNodeList childNodeLst = node.ChildNodes;
foreach (XmlNode childNode in childNodeLst)
{
name = childNode.FirstChild.Attributes[ "name "].Value.Trim();
if (name == "你要的数据 ")
{
//..
}
}
}
------解决方案--------------------Asp.net 2.0 XML 教程示例;
XML学习(Working with XML)
1.幻灯片课程
下载: http://www.cnblogs.com/Files/ChengKing/Working%20with%20XML(ppt).rar
2.示例代码
下载: http://www.cnblogs.com/Files/ChengKing/Working%20with%20XML(project).rar
http://blog.csdn.net/ChengKing/archive/2006/03/31/646363.aspx