xml – 如何比较xpath中的日期以选择节点
发布时间:2020-12-16 00:01:27 所属栏目:百科 来源:网络整理
导读:我想根据xpath中给出的条件获取节点以进行日期比较.我怎么能用xpath做到这一点? 我需要使用adjust-dateTime-to-timezone吗? XPath 2.0有一个 number of date/time functions and operators来帮助处理日期. 假设您有一个这样的XML文档: doc event date="20
我想根据xpath中给出的条件获取节点以进行日期比较.我怎么能用xpath做到这一点?
我需要使用adjust-dateTime-to-timezone吗?
XPath 2.0有一个
number of date/time functions and operators来帮助处理日期.
假设您有一个这样的XML文档: <doc> <event date="2011-02-05">foo</event> <event date="2011-08-01">bar</event> <event date="2011-08-20">baz</event> <event date="2011-11-07">qux</event> </doc> 并且您希望通过@date过滤2011年8月的事件. 你可以使用这个XPath: /doc/event[xs:date(@date) le xs:date('2011-08-31') and xs:date(@date) ge xs:date('2011-08-01')] 它会选择bar和baz的事件元素. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |