XPath : select 只有当一个值低于同一节点中的另一个值时的元素

XPath : select only element when a value is lower than another in the same node

我的 XPath 有问题。对于 WP ALL IMPORT,我需要 select 仅导入低于同一节点中另一个值的值。在这种情况下,我需要 select 个节点,其中 search_price 中的值低于 rrp_price。我阅读了 Whosebug 上的所有内容,但没有任何内容与这种情况相对应。你能帮助我吗 ?我正在与运营商挠头,但我找不到好的方法。谢谢

我的 XPath 基础是 /product

一个产品的示例:

<product> <rrp_price> 192.90 </rrp_price> <search_price> 172.90 </search_price> </product>

根据您的 xml 的确切结构,此 xpath 表达式

//product[./search_price < ./rrp_price]

(或类似的东西)应该为您提供所有 product 节点,这些节点的 search_price child 的值低于 [=13] 中的值=]节点child.

编辑:翻译成"plain English"表达式的意思是:select任何节点(//)名称为product,它有([后来 ]) 一个 child (./) 称为 search_price,其中 child 有一个值(请注意,在这种情况下,xpath 默默地假定当您引用对于 child,您指的是它的数值;如果不是这种情况,则需要发布更明确的指令),它低于(<)另一个 child,共 product,名称为 rrp_price