开发手册 欢迎您!
软件开发者资料库

XPath - 谓词

XPath Predicate - 从基本概念到高级概念的简单简单步骤学习XPath,其中包括概述,表达式,节点,元素,属性,文本,注释,绝对路径,相对路径,轴,运算符,通配符,谓词等。

谓词是指用方括号写的XPath表达式.它指的是为某些条件限制节点集中的选定节点.例如,

S.No.Predicate&描述
1

/class/student [1]

选择第一个学生元素,它是类元素的子元素.

2

/class/student [last()]

选择最后一个学生元素,它是类元素的子元素.

3

/class/student [@rolllno = 493]

使用rollno 493选择student元素.

4

/class/student [marks> 85]

选择带有标记的学生元素> 85.

示例

此示例创建一个表< student>元素及其细节,通过迭代每个学生.它计算学生节点的位置,然后打印学生的详细信息以及序列号.

students.xml

         Dinkar      Kad      Dinkar      85            Vaneet      Gupta      Vinni      95            Jasvir      Singh      Jazz      90   

students.xsl

                                

Students

                                              Roll No                  First Name                  Last Name                  Nick Name                  Marks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         85]">                                                                                                                                                                                              

验证输出

格式化谓词输出