Xpath,两个值之间的范围,如何? [英] Xpath, a range between two values, how?

查看:29
本文介绍了Xpath,两个值之间的范围,如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于使用 Xpath 过滤数据馈送的问题.我想要的是:我想选择 30% 和 50% 折扣之间的所有产品.阅读本网站后我已经尝试过但没有奏效:
/node[price div price_from from<=.7 to<=.5]
/node[price div price_from from <=.7 to <=.5]
node[price div price_from @from <=.7 and .5 <= @to]
/node[price div price_from from <=".7" to <=".5"]
我不知道我还能尝试什么.有没有人能解决我的头痛问题?

I have a question about filtering a datafeed with an Xpath. What I want: I want to select all the products between 30% en 50% percent discount. What I’ve already tried after reading this website and didn’t work:
/node[price div price_from from<=.7 to<=.5]
/node[price div price_from from <=.7 to <=.5]
node[price div price_from @from <=.7 and .5 <= @to]
/node[price div price_from from <=".7" to <=".5"]
I don’t know what I could try more. Does anyone has a solution for my headache caused problem?

谢谢!

推荐答案

假设 XML 输入如下:

Assuming XML input like this:

<nodes>
    <node>
        <price>30</price>
        <price_from>60</price_from>
    </node>
</nodes>

以下 XPath 表达式将匹配折扣介于 30% 和 50% 之间的节点.很简单,你有正确的想法,只需要修复语法:

The following XPath expression will match the nodes that have been discounted anywhere between 30 and 50 percent. It's pretty straightforward, you had the correct idea, just needed to fix the syntax:

//node[(price div price_from >= 0.5) and (price div price_from <= 0.7)]

这篇关于Xpath,两个值之间的范围,如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆