jandre
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2011
10:20 AM
Processing XML sub-categories
I am trying to see the best to way to display and process sub-categories in my xml
for eg, I have an xml something like the following.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>
<category title="Browse Movies" description="Browse Movies" sd_img="movie.png" hd_img="movies.png">
<categorysub title="Movie Genres" description="Movie Genres" sd_img="movie_genre.png" hd_img="movie_genre.png">
<categoryLeaf title="Action" description="" feed="Action.xml"/>
<categoryLeaf title="Drama" description="" feed="drama.xml" />
</categorysub>
<categorysub title="Movies By Collection" description="Movies By Collection" sd_img="movie_collection.png" hd_img="movie_collection.png">
<categoryLeaf title="Disney" description="" feed="Disney.xml"/>
<categoryLeaf title="Imax" description="" feed="Imax.xml" />
</categorysub>
</category>
</categories>
Process flow would be :
Browse Movies ( Home screen - roPosterScreen) --> Movie Genres(roPosterScreen) ---> Action , Drama (roPosterScreen) ---> feed (roSpringBoardScreen )
Would like to see how I can modify the video player example to achieve this.
Thanks for any pointers.
for eg, I have an xml something like the following.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>
<category title="Browse Movies" description="Browse Movies" sd_img="movie.png" hd_img="movies.png">
<categorysub title="Movie Genres" description="Movie Genres" sd_img="movie_genre.png" hd_img="movie_genre.png">
<categoryLeaf title="Action" description="" feed="Action.xml"/>
<categoryLeaf title="Drama" description="" feed="drama.xml" />
</categorysub>
<categorysub title="Movies By Collection" description="Movies By Collection" sd_img="movie_collection.png" hd_img="movie_collection.png">
<categoryLeaf title="Disney" description="" feed="Disney.xml"/>
<categoryLeaf title="Imax" description="" feed="Imax.xml" />
</categorysub>
</category>
</categories>
Process flow would be :
Browse Movies ( Home screen - roPosterScreen) --> Movie Genres(roPosterScreen) ---> Action , Drama (roPosterScreen) ---> feed (roSpringBoardScreen )
Would like to see how I can modify the video player example to achieve this.
Thanks for any pointers.
7 REPLIES 7

RokuKevin
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2011
11:51 AM
Re: Processing XML sub-categories
There are several approaches to this... I would think the quickest way is to leverage the current structure of the videoplayer app.
Following the structure of the videoplayer example, you may want to break up the subcategories into its own xml file. You could then copy categoryFeed.brs to subCategoryFeed.brs and modify both so that you can parse the new level of categories. I'd also use preShowHomeScreen() and showHomeScreen() as templates for preShowSubCategory() and showCategoryScreen() methods.
Hope this gets you started...
--Kevin
Following the structure of the videoplayer example, you may want to break up the subcategories into its own xml file. You could then copy categoryFeed.brs to subCategoryFeed.brs and modify both so that you can parse the new level of categories. I'd also use preShowHomeScreen() and showHomeScreen() as templates for preShowSubCategory() and showCategoryScreen() methods.
Hope this gets you started...
--Kevin
jandre
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2011
05:19 PM
Re: Processing XML sub-categories
Thanks Kevin!
So do you mean something like the following.
categories.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>
<category title="Browse Movies" description="Browse Movies" sd_img="movie.png" hd_img="movies.png">
<categoryLeaf title="Browse movies" description="" feed="subcategory.xml" />
</category>
</categories>
subcategory.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>
<category title="Movie Genres" description="Movie Genres" sd_img="movie_genre.png" hd_img="movie_genre.png">
<categoryLeaf title="Action" description="" feed="Action.xml"/>
<categoryLeaf title="Drama" description="" feed="drama.xml" />
</category>
<category title="Movies By Collection" description="Movies By Collection" sd_img="movie_collection.png" hd_img="movie_collection.png">
<categoryLeaf title="Disney" description="" feed="Disney.xml"/>
<categoryLeaf title="Imax" description="" feed="Imax.xml" />
</category>
</categories>
also can we initialize both category and subCategory screens in AppMain.brs something like this?
Sub Main()
'initialize theme attributes like titles, logos and overhang color
initTheme()
'prepare the screen for display and get ready to begin
screen=preShowHomeScreen("", "")
subscreen=preShowSubCategory("", "")
if screen=invalid then
print "unexpected error in preShowHomeScreen"
return
end if
'set to go, time to get started
showHomeScreen(screen)
showCategoryScreen(subscreen)
End Sub
Also initialize subcategories.xml in InitSubCategoryFeedConnection() of subCategoryFeed.brs
Function InitSubCategoryFeedConnection() As Object
conn = CreateObject("roAssociativeArray")
conn.UrlPrefix = "http://test.com/roku/videoplayer/xml"
conn.UrlCategoryFeed = conn.UrlPrefix + "/subcategories.xml"
conn.Timer = CreateObject("roTimespan")
conn.LoadCategoryFeed = load_sub_category_feed
conn.GetCategoryNames = get_sub_category_names
print "created feed connection for " + conn.UrlCategoryFeed
return conn
End Function
Let me know if I am on the right track?
So do you mean something like the following.
categories.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>
<category title="Browse Movies" description="Browse Movies" sd_img="movie.png" hd_img="movies.png">
<categoryLeaf title="Browse movies" description="" feed="subcategory.xml" />
</category>
</categories>
subcategory.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>
<category title="Movie Genres" description="Movie Genres" sd_img="movie_genre.png" hd_img="movie_genre.png">
<categoryLeaf title="Action" description="" feed="Action.xml"/>
<categoryLeaf title="Drama" description="" feed="drama.xml" />
</category>
<category title="Movies By Collection" description="Movies By Collection" sd_img="movie_collection.png" hd_img="movie_collection.png">
<categoryLeaf title="Disney" description="" feed="Disney.xml"/>
<categoryLeaf title="Imax" description="" feed="Imax.xml" />
</category>
</categories>
also can we initialize both category and subCategory screens in AppMain.brs something like this?
Sub Main()
'initialize theme attributes like titles, logos and overhang color
initTheme()
'prepare the screen for display and get ready to begin
screen=preShowHomeScreen("", "")
subscreen=preShowSubCategory("", "")
if screen=invalid then
print "unexpected error in preShowHomeScreen"
return
end if
'set to go, time to get started
showHomeScreen(screen)
showCategoryScreen(subscreen)
End Sub
Also initialize subcategories.xml in InitSubCategoryFeedConnection() of subCategoryFeed.brs
Function InitSubCategoryFeedConnection() As Object
conn = CreateObject("roAssociativeArray")
conn.UrlPrefix = "http://test.com/roku/videoplayer/xml"
conn.UrlCategoryFeed = conn.UrlPrefix + "/subcategories.xml"
conn.Timer = CreateObject("roTimespan")
conn.LoadCategoryFeed = load_sub_category_feed
conn.GetCategoryNames = get_sub_category_names
print "created feed connection for " + conn.UrlCategoryFeed
return conn
End Function
Let me know if I am on the right track?

RokuKevin
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011
09:15 AM
Re: Processing XML sub-categories
You started out on the right track by separating the .xml files. But I was expecting you to modify the code in showHomeScreen() and change the calls:
to
where displaySubCategoryScreen() is defined in your newly created subCategoryFeed.brs.
--Kevin
if kid.type = "special_category" then
displaySpecialCategoryScreen()
else
displayCategoryPosterScreen(kid)
end if
to
displaySubCategoryScreen()
where displaySubCategoryScreen() is defined in your newly created subCategoryFeed.brs.
--Kevin
saravanainfo
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2011
12:49 PM
Re: Processing XML sub-categories
Hello all.. i am new to all this... need a help with an issue that i am facing...
I used the existing example code from the sdk "Videoplayer" and tried to change the url, xml, etc.
i am facing problem with this brs file named "CategoryFeed".
There is a code "conn.UrlPrefix = "http://rokudev.roku.com/rokudev/examples/videoplayer/xml"...
how do I change this part to my xml folder? i tried this following, it didn't work as I expected. can you give me a suggestion?
conn.UrlPrefix = "pkg:/XML"
As i told you, i didn't expect this to work, but need a work around to make it work. please help
I used the existing example code from the sdk "Videoplayer" and tried to change the url, xml, etc.
i am facing problem with this brs file named "CategoryFeed".
There is a code "conn.UrlPrefix = "http://rokudev.roku.com/rokudev/examples/videoplayer/xml"...
how do I change this part to my xml folder? i tried this following, it didn't work as I expected. can you give me a suggestion?
conn.UrlPrefix = "pkg:/XML"
As i told you, i didn't expect this to work, but need a work around to make it work. please help
luke823
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2013
01:13 PM
Re: Processing XML sub-categories
is this still the most current information on sub-categories, or can it be done now without having to write bright script?
b14d3
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2013
06:54 AM
Re: Processing XML sub-categories
"saravanainfo" wrote:
conn.UrlPrefix = "pkg:/XML"
The xml should be in an internet-accessible URL, not contained in the package. http://rokudev.roku.com you can put in a browser and get to it, so follow that as an example and you'll be right as rain.
Blackhawk
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2016
01:42 PM
Re: Processing XML sub-categories
Like this?
conn.UrlPrefix = "rokudev.roku.com/Channel/xml/shows"
conn.UrlCategoryFeed = conn.UrlPrefix + "/Shows.xml"