I want to get nodes based on condition given in xpath for date comparison. How I can do that using xpath?
Do i need to use adjust-dateTime-to-timezone
?
XPath assertion uses XPath expression to select the target node and its values. It compares the result of an XPath expression to an expected value. XPath is an XML query language for selecting nodes from an XML.
Unlike ID attributes, every element in a web page has a unique XPath.
XPath 2.0 has a number of date/time functions and operators to help processing dates.
Assume that you had an XML document like this:
<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 the events by @date
for those in August 2011.
You could 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 it would select the event
elements for bar
and baz
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With