agmark
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2011
01:12 PM
Parsing pubDate in XML
I'm looking for suggestions on parsing the pubDate in an XML feed. The feed gives me a pubDate of:
I have no control over the time, so I'd prefer to strip off the "00:00:00 GMT" in the following parsing code:
Thanks again for any guidance!
~Mark
<pubDate>Wed, 9 Nov 2011 00:00:00 GMT</pubDate>
I have no control over the time, so I'd prefer to strip off the "00:00:00 GMT" in the following parsing code:
' release date
if item.GetNamedElements("blip:datestamp").Count() > 0
dt = CreateObject("roDateTime")
dt.FromISO8601String(ValidStr(item.GetNamedElements("blip:datestamp")[0].GetText()))
newItem.releaseDate = dt.AsDateStringNoParam()
else
newItem.releaseDate = ValidStr(item.pubdate.GetText())
end if
newItem.shortDescriptionLine2 = newItem.releaseDate
' media:content can be a child of <item> or of <media:group>
contentItems = item.GetNamedElements("media:content")
if contentItems.Count() = 0
tmp = item.GetNamedElements("media:group")
if tmp.Count() > 0
contentItems = tmp.GetNamedElements("media:content")
end if
end if
Thanks again for any guidance!
~Mark
2 REPLIES 2
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2011
08:20 PM
Re: Parsing pubDate in XML
If your date string always ends in the following 13 characters: " 00:00:00 GMT", then this should work:
Although, if it may also be of the form " 0:00:00 GMT" then you might want to use:
I haven't tested it out since I don't have my Roku with me, but that should give you somewhere to start. I believe you could also parse your date using an roRegex object (see the Component Reference Manual, section 5.5).
newDate = Left (dateString, Len (dateString) - 13)
Although, if it may also be of the form " 0:00:00 GMT" then you might want to use:
if Mid (dateString, Len (dateString) - 11, 1) = " " then
newDate = Left (dateString, Len (dateString) - 12)
else
newDate = Left (dateString, Len (dateString) - 13)
endif
I haven't tested it out since I don't have my Roku with me, but that should give you somewhere to start. I believe you could also parse your date using an roRegex object (see the Component Reference Manual, section 5.5).
agmark
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2011
09:05 AM
Re: Parsing pubDate in XML
Thanks belltown. Your first suggestion worked. I'll experiment with your other ideas too.