XPath 2.0 has a number of date and time functions and operators to help process dates.
Suppose you had an XML document:
<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>
and you want to filter out @date events for those in August 2011.
You can use this XPath:
/doc/event[xs:date(@date) le xs:date('2011-08-31') and xs:date(@date) ge xs:date('2011-08-01')]
and he will select event elements for bar and baz .
source share