SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Jul 12, 2002, 13:20 #1
- Join Date
- Dec 2001
- Location
- erie, pa
- Posts
- 1,130
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
how do you specifiy a date range in an xpath expression?
i'm trying to get only "/headlines/headline" elements from an xml document which have attributes "startDate" and "endDate" in which the current date falls between them. here's what i have that isn't working correctly:
Code:/headlines/headline[@startDate <= '2002-07-12' and @endDate >= '2002-07-12']
-
Jul 12, 2002, 20:25 #2
- Join Date
- Jan 2002
- Location
- London
- Posts
- 3,509
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'll be on the case in the morning.... must sleeeeeeeeep!
MarcusJT
- former ASP web developer / former SPF "ASP Guru"
- *very* old blog with some useful ASP code
- Please think, Google, and search these forums before posting!
-
Jul 13, 2002, 06:06 #3
- Join Date
- Jan 2002
- Location
- London
- Posts
- 3,509
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
To start with, unless you have actually specified the data type for startDate, it's just a string to the XML parser, and so it won't be able to make comparisons of the type you are attempting.
Assuming for the moment that you are using the Microsoft XML parser, you will need to invoke the Microsoft datatype namespace, and specify that the startDate is of type "date".
If you are able to turn this attribute into an element, then it is easier to do so, since you can then do this:Code:<?xml version='1.0'?> <?xml-stylesheet type="text/xsl" href="Sample.xsl"?> <headlines xml:space="preserve" xmlns:dt="urn:schemas-microsoft-com:datatypes"> <startDate dt:dt="date">2002-07-12</startDate> <otherelement>stuff here</otherelement> </headlines>
Anyway, once the datatype has been defined in this way, you should find yourself able to perform comparions in the way that you desire, although you will need to modify your current XPath expression accordingly if you have indeed turned the attribute into an element.MarcusJT
- former ASP web developer / former SPF "ASP Guru"
- *very* old blog with some useful ASP code
- Please think, Google, and search these forums before posting!
-
Jul 15, 2002, 16:48 #4
- Join Date
- Jan 2002
- Location
- London
- Posts
- 3,509
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Any joy with that, CrowDozer?
MarcusJT
- former ASP web developer / former SPF "ASP Guru"
- *very* old blog with some useful ASP code
- Please think, Google, and search these forums before posting!
-
Jul 16, 2002, 05:56 #5
- Join Date
- Dec 2001
- Location
- erie, pa
- Posts
- 1,130
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
no i decided to just return all of them and programaticaly determine which get displayed. which is ok because there won't be a whole lot of results and sometimes i have to display them all anyways.
-
Jul 16, 2002, 12:42 #6
- Join Date
- Jan 2002
- Location
- London
- Posts
- 3,509
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok!
MarcusJT
- former ASP web developer / former SPF "ASP Guru"
- *very* old blog with some useful ASP code
- Please think, Google, and search these forums before posting!
Bookmarks