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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Roku Guru

Screengraph error

I was setting up the


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


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 = {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() = "loadContent"

End Sub

Sub loadContent()

list = GetContentFeed() = 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")



end for


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
0 Kudos
Community Streaming Expert

Re: Screengraph error

This line:
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
Roku Guru

Re: Screengraph error

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