日期:2014-05-20  浏览次数:20949 次

Xpath 查询 在线等~~~急~~~~~~~~~~~
<?xml   version= '1.0 '   encoding= "UTF-8 "   standalone= "yes "?>
<Enrolment   Register= "李济明 "   Date= "2001-09-01 ">
<Students>
<Student   StudentNo= "0208123 "   Sex= "男 ">
<Name> 王义平 </Name>
<BirthDate> 1984-08-20 </BirthDate>
<CourseTaken> EE-122 </CourseTaken>
<CourseTaken> EE-201 </CourseTaken>
</Student>
<Student   StudentNo= "0104421 "   Sex= "男 ">
<Name> 周远行 </Name>
<BirthDate> 1984-07-16 </BirthDate>
<CourseTaken> CS-110 </CourseTaken>
<CourseTaken> EE-201 </CourseTaken>
</Student>
<Student   StudentNo= "0309119 "   Sex= "女 ">
<Name> 李   维 </Name>
<BirthDate> 1984-08-01 </BirthDate>
<CourseTaken> CS-110 </CourseTaken>
<CourseTaken> CS-201 </CourseTaken>
</Student>
</Students>
<Courses>
<Course   CourseNo= "CS-110 "   Credit= "3 ">
<LectureHour> 60 </LectureHour>
<Semester> 秋 </Semester>
</Course>
<Course   CourseNo= "CS-201 "   Credit= "4 ">
<LectureHour> 80 </LectureHour>
<Semester> 春 </Semester>
</Course>
<Course   CourseNo= "EE-122 "   Credit= "5 ">
<LectureHour> 106 </LectureHour>
<Semester> 秋 </Semester>
</Course>
<Course   CourseNo= "EE-201 "   Credit= "2 ">
<LectureHour> 45 </LectureHour>
<Semester> 春 </Semester>
</Course>
</Courses>
</Enrolment>

列出选修CS-110课程的学生姓名、学号和出生日期  
我只能用三条语句分别列出:
/Enrolment/Students/Student[CourseTaken= "CS-110 "]/Name
/Enrolment/Students/Student[CourseTaken= "CS-110 "]/@StudentNo
/Enrolment/Students/Student[CourseTaken= "CS-110 "]/BirthDate

请问如何用一条语句一起输出,谢谢

------解决方案--------------------
支持liujia_0421(SnowLover)
------解决方案--------------------
写反了..

XmlDocument doc = new XmlDocument();
doc.Load( "../../student.xml ");
XmlNodeList nodelist = doc.SelectNodes(@ "/Enrolment/Students/Student[CourseTaken= 'CS-110 '] ");
foreach (XmlNode node in nodelist)
{
Debug.WriteLine( "StudentName: " + node.ChildNodes[0].InnerText + "\tStudentNO: " + node.Attributes[ "StudentNo "].Value + "\tBirthDate: " + node.ChildNodes[1].InnerText);
}

输出:

StudentName: 周远行 StudentNO: 0104421 BirthDate: 1984-07-16
StudentName: 李 维 StudentNO: 0309119 BirthDate: 1984-08-01
------解决方案--------------------
不行
------解决方案--------------------
up,leran,mark.