如何乘以 XPATH 中的值? [英] How to multiply values in XPATH?

查看:27
本文介绍了如何乘以 XPATH 中的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一堆

<item price='n' sold='m'>
...
</item>

我想对每件商品进行价格 * 销售.我正在尝试

I want to do price * sold on each of the items. I am trying

'//item/(@price * @sold)' 

来自 python 中的 lxml,但我不断收到错误 'Invalid Expression'.xmllint 命令也会发生同样的情况.但同样的查询在 Oxygen xml 编辑器中有效.

from inside lxml in python, but I keep getting the error 'Invalid Expression'. The same happens with xmllint command too. But the same query works in Oxygen xml editor.

我如何使这项工作?

推荐答案

计算可以在 XPath 2.0 中完成,因为我已经更正了!

Calculations can be done in XPath 2.0 as I have been corrected!

如果您想选择价格低于或等于售价乘以 2 的所有商品,这是可能的.见下:http://en.wikipedia.org/wiki/XPath#Number_functions

If you want to select everything where the price is lower or equal than sold price times 2 it is possible. See next: http://en.wikipedia.org/wiki/XPath#Number_functions

这篇关于如何乘以 XPATH 中的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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