I have orders.xml like the following
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<orders>
<order orderDate="1/1/2009" orderNo="1">
<customer id="nnghiem" name="nguyen nghiem"/>
<item id="item-1" price="25000" quantity="0"/>
<item id="item-2" price="22000" quantity="3"/>
</order>
<order orderDate="2/2/2009" orderNo="2">
<customer id="lp" name="lampard"/>
<item id="item-1" price="25000" quantity="2"/>
<item id="item-2" price="22000" quantity="8"/>
</order>
<order orderDate="3/3/2007" orderNo="3">
<customer id="nnghiem" name="nguyen nghiem"/>
<item id="item-1" price="25000" quantity="7"/>
<item id="item-2" price="22000" quantity="6"/>
</order>
</orders>
I want to retrieve every order in '2009
I solved this problem by the following way:
String exp = "/orders/order[substring(@orderDate,string-length(@orderDate)-3)='2009']";
//... some code lines
I wonder is there any way to compare date in this situation like this:
String exp = "/orders/order[@orderDate<'31/12/2009' and @orderDate>'1/1/2009']";
// get all orders between 1/1/2009 and 31/12/2009 (in year 2009)
but this exp will not return the expected result
How to solve this problem?
Thanks for your attention!