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: 
xoceunder
Roku Guru

separate from the xml file each category with its item to show

Helps you pull out content to show

My content http://144.217.94.67/xml/series.xml

My function to display content in the grid scene
Function GetDataMovies()
readInternet=createObject("roUrlTransfer")
readInternet.setUrl(m.top.uri)
source=readInternet.GetToString()
responseXML=ParseXML(source)
responseXML=responseXML.GetChildElements()
responseArray=responseXML.GetChildElements()

oneRow=[]
twoRow=[]
c=0

For Each xmlItem In responseArray
If xmlItem.getName()="item"
itemAA=xmlItem.GetChildElements()
  If itemAA<>invalid
  item={}
For Each xmlItem In itemAA
  item[xmlItem.getName()]=xmlItem.getText()
  If xmlItem.getName()="media:content"
  item.url=xmlItem.getAttributes().url
  item.streamFormat="mp4"

  mediaContent=xmlItem.GetChildElements()
  For Each mediaContentItem In mediaContent
  If mediaContentItem.getName()="media:thumbnail"
item.HDPosterUrl=mediaContentItem.getattributes().url
  item.hdBackgroundImageUrl=mediaContentItem.getattributes().url
  End If
Next
  End If
  Next
If (c/2)=Int(c/2)
oneRow.Push(item)
Else
twoRow.Push(item)
End If
c=c+1
End If
End If
Next

list=[
{
TITLE : "First row"
ContentList : oneRow
}
{
TITLE : "Second row"
ContentList : twoRow
}
]

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

For x=0 To list.Count()-1
row=createObject("RoSGNode","ContentNode")
row.Title=list[x].Title
For Each itemAA In list[x].ContentList
item=createObject("RoSGNode","ContentNode")
item.Title=itemAA.Title
item.description=itemAA.description
item.url=itemAA.url
item.streamFormat="mp4"
item.releasedate=itemAA.pubDate
item.HDPosterURL=itemaa.HDPosterURL
item.hdbackgroundimageurl=itemaa.hdbackgroundimageurl
row.AppendChild(item) 'Add each individual item
End For
RowItems.AppendChild(row) 'Add each individual category of items
Next
m.top.content=RowItems 'set top content field to the entire screen's content which will cause the content observer to notice
End Function


But I want to be able to make it possible to place each category the name with its content as it could make this possible
0 Kudos
2 REPLIES 2
xoceunder
Roku Guru

Re: Helps you pull out content to show

How can i separate from the xml file each category with its item to show in GridScreen
0 Kudos
destruk
Streaming Star

Re: separate from the xml file each category with its item to show

Just if anyone else using the sample feed for this - how to dynamically get the category names from a feed based on that link above -

Function GetDataMovies()
readInternet=createObject("roUrlTransfer")
readInternet.setUrl(m.top.uri)
source=readInternet.GetToString()
responseXML=ParseXML(source)
responseXML=responseXML.GetChildElements()
responseArray=responseXML.GetChildElements()

content=[]
CategoryNames=[]
numofcategories=responsearray.Count()-1
For c=1 To numofcategories
CategoryNames.Push(responsearray[c]@name)
temparray=[]
For x=0 To responsearray[c].item.Count()-1
itemAA=responsearray[c].item[x].GetChildElements()
  item={}
For Each xmlItem In itemAA
item[xmlItem.getName()]=xmlItem.getText()
If xmlItem.getName()="media:content"
item.url=xmlItem.getAttributes().url
item.streamFormat="mp4"
mediaContent=xmlItem.GetChildElements()
For Each mediaContentItem In mediaContent
If mediaContentItem.getName()="media:thumbnail"
item.HDPosterUrl=mediaContentItem.getattributes().url
item.hdBackgroundImageUrl=mediaContentItem.getattributes().url
End If
Next
End If
Next
temparray.Push(item)
Next
content.Push(temparray)
Next

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

For x=0 To CategoryNames.Count()-1
row=createObject("RoSGNode","ContentNode")
row.Title=CategoryNames[x]
For Each itemAA In content[x]
item=createObject("RoSGNode","ContentNode")
item.Title=itemAA.Title
item.description=itemAA.description
item.url=itemAA.url
item.streamFormat="mp4"
item.releasedate=itemAA.pubDate
item.HDPosterURL=itemaa.HDPosterURL
item.hdbackgroundimageurl=itemaa.hdbackgroundimageurl
row.AppendChild(item) 'Add each individual item
Next
RowItems.AppendChild(row) 'Add each individual category of items
Next
m.top.content=RowItems 'set top content field to the entire screen's content which will cause the content observer to notice
End Function

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.