Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
agmark
Visitor

Parsing pubDate in XML

I'm looking for suggestions on parsing the pubDate in an XML feed. The feed gives me a pubDate of:
<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
0 Kudos
2 REPLIES 2
belltown
Roku Guru

Re: Parsing pubDate in XML

If your date string always ends in the following 13 characters: " 00:00:00 GMT", then this should work:

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).
0 Kudos
agmark
Visitor

Re: Parsing pubDate in XML

Thanks belltown. Your first suggestion worked. I'll experiment with your other ideas too.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.