| | |
How to Compare Date in XPath Expression
Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2009
Posts: 3
Reputation:
Solved Threads: 0
I have orders.xml like the following
I want to retrieve every order in '2009
I solved this problem by the following way:
I wonder is there any way to compare date in this situation like this:
// 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!
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<?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:
XML, XSLT and XPATH Syntax (Toggle Plain Text)
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:
XML, XSLT and XPATH Syntax (Toggle Plain Text)
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!
![]() |
Similar Threads
- Xpath expression (XML, XSLT and XPATH)
- XPath expression for <td> tag having "Type" as textContent in any of its childNodes (XML, XSLT and XPATH)
- compare date in c#.net 2005 (C#)
- Xpath question (XML, XSLT and XPATH)
- Compare date of database with current date (PHP)
- compare excel dates (Windows Software)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: XML
- Next Thread: Editing XPath Count function in SharePoint Dataview
| Thread Tools | Search this Thread |
api blogger blogging code delete development dynamiccreationofnvariablesinxslt error firstthreecharacterofastringrequired flipbook gdata google html include java link linspire linux microsoft news node openoffice overwrite precedence programming rss standards swf template transform variable w3c web xml xmlnotloading xmlonserver xsl xslt






