Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
Blackhawk
Level 7

Screengraph error

I was setting up the
FeedParser

script

Function ParseXML(str As String) As dynamic 'Takes in the content feed as a string

if str = invalid return invalid 'if the response is invalid, return invalid

xml = CreateObject("roXMLElement") '

if not xml.Parse(str) return invalid 'If the string cannot be parsed, return invalid

return xml 'returns parsed XML if not invalid

End Function

 

 

Function GetContentFeed() 'This function retrieves and parses the feed and stores each content item in a ContentNode

url = CreateObject("roUrlTransfer") 'component used to transfer data to/from remote servers

url.SetUrl("http://griffingatv.website/feed.rss)

rsp = url.GetToString() 'convert response into a string

responseXML = ParseXML(rsp) 'Roku includes it's own XML parsing method

if responseXML<>invalid then 'Fall back in case Roku's built in XML Parse method fails

responseXML = responseXML.GetChildElements() 'Access content inside Feed

responseArray = responseXML.GetChildElements()

End if

'manually parse feed if ParseXML() is invalid

result = [] 'Store all results inside an array. Each element represents a row inside our RowList stored as an Associative Array (line 63)

for each xmlItem in responseArray 'For loop to grab content inside each item in the XML feed

if xmlItem.getName() = "item" 'Each individual channel content is stored inside the XML header named <item>

itemAA = xmlItem.GetChildElements() 'Get the child elements of item

if itemAA <> invalid 'Fall back in case invalid is returned

item = {} 'Creates an Associative Array for each row

for each xmlItem in itemAA 'Goes through all content of itemAA

item[xmlItem.getName()] = xmlItem.getText()

if xmlItem.getName() = "media:content" 'Checks to find <media:content> header

item.stream = {url : xmlItem.url} 'Assigns all content inside <media:content> to the item AA

item.url = xmlItem.getAttributes().url

item.streamFormat = "mp4"

mediaContent = xmlItem.GetChildElements()

for each mediaContentItem in mediaContent 'Looks through MediaContent to find poster images for each piece of content

if mediaContentItem.getName() = "media:thumbnail"

item.HDPosterUrl = mediaContentItem.getattributes().url 'Assigns images to item AA

item.hdBackgroundImageUrl = mediaContentItem.getattributes().url

end if

end for

end if

end for

result.push(item) 'Pushes each AA into the Array

end if

end if

end for

return result ' Returns the array

End Function

Sub Init()

m.top.functionName = "loadContent"

End Sub

Sub loadContent()

list = GetContentFeed()

m.top.content = ParseXMLContent(list)

End Sub

Function ParseXMLContent(list As Object) 'Formats content into content nodes so they can be passed into the RowList

RowItems = createObject("RoSGNode","ContentNode")

'Content node format for RowList: ContentNode(RowList content) --<Children>-> ContentNodes for each row --<Children>-> ContentNodes for each item in the row)

for each rowAA in list

row = createObject("RoSGNode","ContentNode")

row.Title = rowAA.Title

for each itemAA in rowAA.ContentList

item = createObject("RoSGNode","ContentNode")

item.SetFields(itemAA)

row.appendChild(item)

end for

RowItems.appendChild(row)

end for

return RowItems

End Function




And I came across this error
String missing ending quote. (compile error &hb3) in pkg:/source/FeedParser.brs(16)

I did everything this tutorial said but I keep getting errors
https://github.com/rokudev/docs/blob/master/develop/sdk-development/parsing-feed.md
0 Kudos
2 Replies
renojim
Level 8

Re: Screengraph error

This line:
url.SetUrl("http://griffingatv.website/feed.rss)
0 Kudos
Blackhawk
Level 7

Re: Screengraph error

Is there any way I can use XML instead of RSS?
0 Kudos