Forum Discussion
belltown
10 years agoRoku Guru
Function getShowsForCategoryItem(category As Object) As Object
xfer = CreateObject("roURLTransfer")
xfer.SetURL("http://cs2308.mojohost.com/watchindie.info/public_html/xml/Action.xml")
webService = xfer.GetToString()
showList = []
stop
xml = CreateObject("roXMLElement")
if xml.Parse(webService) ' where xmlString is a chunk of valid XML you've fetched from some cloud service
for each item in xml.item
showList.Push({
Title: item.title.GetText()
ReleaseDate: item.contentId.GetText()
Description: item.synopsis.GetText()
HDPosterUrl: item@hdimg
SDPosterUrl: item@sdimg
})
end for
end if
End Function
Put the 'stop' statement in for debugging purposes. You can then use the debugger 'step' command to see line-by-line which code gets executed. If you get to the 'for' statement after the 'xml.Parse' then the xml parsed successfully. As you step past each line of code, examine the variables that your code is setting to see if the expected value actually gets set, e.g. ?Title
The xml code is rather confusing, but basically 'xml' should contain your parsed xml tree. Your 'for each' statement sets the 'item' variable to each Xml <item> in turn (no need to reference <feed> because that's your root element, which is what 'xml' is referrring to). Once you have the 'item' iterator in your 'for each' loop, select its child elements using the "." operator, and its attributes using the @ operator.
And it looks like you had an 'end for' instead of an 'end if'