简体   繁体   English

如何在xpath中将十进制转换为整数?

[英]How to convert decimal to integer in xpath?

The input xml includes the following element: 输入xml包含以下元素:

<numberOfPayments>14.0</numberOfPayments>

I need to convert the number to integer, with following limitations: 我需要将数字转换为整数,但有以下限制:

  • the XML is coming from an external source, I cant ask them to send me the integer XML来自外部源,我不能让他们给我发整数
  • it has to be an XPath, I can't use any other language 它必须是一个XPath,我不能使用任何其他语言

You can use round() . 你可以使用round() The xpath query would be: xpath查询将是:

round(/numberOfPayments/text())

or if you are only interested in the integer part without rounding you can use floor() : 或者如果您只对整数部分感兴趣而不进行舍入,则可以使用floor()

floor(/numberOfPayments/text())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM