Writing XML Xpath expression with checking two attributes

时间:2018-01-24 09:47:34

标签: xml xpath

<?xml version="1.0" encoding="UTF-8"?>
<Employees>
    <Employee id="1">
        <age>29</age>
        <name>Pankaj</name>
        <gender>Male</gender>
        <role>CEO</role>
    </Employee>
    <Employee id="2">
        <age>35</age>
        <name>Lisa</name>
        <gender>Female</gender>
        <role>CEO</role>
    </Employee>
<Employees>

How write xpath for getting name whose role is CEO and age is 35?

/Employees/Employee[age="35 "]/name/text() 

The xpath above return name whose age is 35, i need to add condition(role=ceo) to that xpath

1 个答案:

答案 0 :(得分:0)

window.frames['myIFrame'].contentDocument 添加另一个谓词:

Employee

或将两个条件组合在一个谓词中:

/Employees/Employee[age=35][role="CEO"]/name/text()