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

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).

Thanks belltown. Your first suggestion worked. I’ll experiment with your other ideas too.