有没有办法比较 xpath 表达式中的时间?

Is there a way to compare times in an xpath expression?

所以,对于我的 XML 我有这个:

<venues>
<venue venueID="1">
  <name>Nillington Center</name>
  <location>Nullville</location>
  <capacity>10000</capacity>
  <openingTime>07:00:00</openingTime>
  <closingTime>22:00:00</closingTime>
  <Manager>DJ8S1L0</Manager>
  <telephone>01101 111011</telephone>
</venue>

是否可以构造一个 Xpath 表达式来计算,假设有多个场地,openingTime > '18:00:00',如果可以,如何计算?

比较适用于整数,例如我可以毫无问题地得到类似的东西 /venues/venue[capacity > 8000] 工作但没时间。

任何帮助将不胜感激:)

试试这个:

venues/venue[number(translate(substring(openingTime, 1, 5), ":", ".")) &gt; 18]

步骤:

  • 删除秒部分(我认为这不重要)
  • 将“:”换成小数,这样字符串就可以进行数字转换(换句话说,18:00 变为 18.00)
  • 将小时和分钟部分转换为数字(这使比较有效)