📜  XPath-谓词

📅  最后修改于: 2020-11-09 05:40:02             🧑  作者: Mango


谓词是指用方括号括起来的XPath表达式。它指的是出于某些条件限制节点集中的选定节点。例如,

S.No. Predicate & Description
1

/class/student[1]

Select first student element which is child of the class element.

2

/class/student[last()]

Select last student element which is child of the class element.

3

/class/student[@rolllno = 493]

Select student element with rollno 493.

4

/class/student[marks>85]

Select student element with marks > 85.

本示例通过遍历每个学生来创建带有其详细信息的元素表。它计算学生节点的位置,然后打印学生详细信息以及序列号。

students.xml




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

students.xsl


  

   

验证输出

格式化谓词输出