This discussion is archived
1 Reply Latest reply: Aug 21, 2012 7:00 PM by 955682 RSS

handling invalid datetime

955682 Newbie
Currently Being Moderated
I am learning and using dbxml 2.5.16 for a Django project involving xml feeds roughly structured like this:

<rss>
<channel>
<item>
<content></content>
<date></date>
</item>
</channel>
</rss>

I have to figure out a query string selecting item objects by date elements, comparing a year and/or month and/or day value to an integer value I provide by URl.
Problem is that date elements in my xml file are formatted like this:<date>Fri, 03 Aug 2012 11:56:58 GMT</date>
I would like to convert the date and do the comparison inside my querystring, without accessing the document.
Is it possible?
Or should I reformat all date elements using python's strptime() on the xml before I put it in my container?

What I have in mind is this sort of thing (obviously not working):

yrset = r"collection()/rss/channel/item[(time.strptime(pubDate,'%a %d %b %Y %H %M %S %Z').tm_year = year ) and enclosure/@url = key]"


my thanks

Renato
  • 1. Re: handling invalid datetime
    955682 Newbie
    Currently Being Moderated
    A little update: I actually got by with a simple query that performs a replace on month names, this might be enough. What is looking ugly now is that i prepare and execute a separate query for each month name. I could not come up with a less unseemly way to group a multiple replace.
    I took a shot at replace-multi(xquery) and format-dateTime(xpath 2.0) but I couldn'get them to work.
    Recursive function maybe?
    I want to replace a set of node values , returning them with the right number representing the month value instead of a name substring, e.g. 08 instead of Aug.
    Sorry for my poor English and skills, I'm taking my time to learn.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points