日期:2014-05-20 浏览次数:20491 次
<class> <student> <no>1</no> <name>Ann</name> <sex>female</sex> <age>15</age> <score>90</score> </student> <student> <no>2</no> <name>Bob</name> <sex>male</sex> <age>16</age> <score>80</score> </student> <student> …… </student> <student> …… </student> </class>
string strXml = @"<class> <student> <no>1</no> <name>Ann</name> <sex>female</sex> <age>15</age> <score>90</score> </student> <student> <no>2</no> <name>Bob</name> <sex>male</sex> <age>16</age> <score>80</score> </student> <student> <no>3</no> <name>ttt</name> <sex>j</sex> <age>15</age> <score>92</score> </student> <student> </student> </class>"; XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(strXml); string strXPath = string.Empty; strXPath = "/class/student[score>=90]"; XmlNodeList oXmlNodes = xdoc.SelectNodes(strXPath); foreach (XmlNode node in oXmlNodes) { string strName = node.SelectSingleNode("/class/student/name").InnerText ; }
------解决方案--------------------
应该是不可以的。就像冰箱里有N多瓶饮料,你能否不开冰箱就喝到其中的一瓶呢。