小编Kir*_*WSI的帖子

xpath中嵌套的条件if else语句

我有这个XML:

<property id="1011">
    <leasehold>No</leasehold>
    <freehold>Yes</freehold>
    <propertyTypes>
        <propertyType>RESIDENTIAL</propertyType>
    </propertyTypes>
</property>
Run Code Online (Sandbox Code Playgroud)

我想创建一个xpath语句,它与下面嵌套的if-else伪代码块相同.

if( propertyTypes/propertyType == 'RESIDENTIAL') {
    if( leasehold == 'Yes' ){
        return 'Rent'
    } else
        return 'Buy'
    }
} else {
    if( leasehold == 'Yes' ){
        return 'Leasehold'
    } else
        return 'Freehold'
    }
}
Run Code Online (Sandbox Code Playgroud)

我已经看到了Becker的方法,但我无法真正遵循它.XPath真的不是我的强项.

xpath conditional if-statement xpath-2.0

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

conditional ×1

if-statement ×1

xpath ×1

xpath-2.0 ×1