# Processing XML sub-categories

**URL:** <https://forum.developer.roku.com/t/processing-xml-sub-categories/1365>\
**Category:** Archived\
**Tags:** roku-developer-program\
**Created:** [February 10, 2011, 6:20pm UTC](https://forum.developer.roku.com/t/processing-xml-sub-categories/1365 "2011-02-10T18:20:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jandre](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jandre](https://forum.developer.roku.com/u/jandre)\
**Post date:** [February 10, 2011, 6:20pm UTC](https://forum.developer.roku.com/t/processing-xml-sub-categories/1365/1 "2011-02-10T18:20:25Z")

</div>

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"?\>

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.

---

<div class="post-metadata">

**Author:** ![RokuKevin](https://avatars.discourse-cdn.com/v4/letter/r/ee7513/32.png) [@RokuKevin](https://forum.developer.roku.com/u/RokuKevin)\
**Post date:** [February 10, 2011, 7:51pm UTC](https://forum.developer.roku.com/t/processing-xml-sub-categories/1365/2 "2011-02-10T19:51:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jandre](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jandre](https://forum.developer.roku.com/u/jandre)\
**Post date:** [February 11, 2011, 1:19am UTC](https://forum.developer.roku.com/t/processing-xml-sub-categories/1365/3 "2011-02-11T01:19:20Z")

</div>

Thanks Kevin!

So do you mean something like the following.

**categories.xml**

\<?xml version="1.0" encoding="UTF-8" standalone="yes"?\>

**subcategory.xml**

\<?xml version="1.0" encoding="UTF-8" standalone="yes"?\>

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](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?

---

<div class="post-metadata">

**Author:** ![RokuKevin](https://avatars.discourse-cdn.com/v4/letter/r/ee7513/32.png) [@RokuKevin](https://forum.developer.roku.com/u/RokuKevin)\
**Post date:** [February 11, 2011, 5:15pm UTC](https://forum.developer.roku.com/t/processing-xml-sub-categories/1365/4 "2011-02-11T17:15:49Z")

</div>

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:

```auto

                if kid.type = "special_category" then
                    displaySpecialCategoryScreen()
                else
                    displayCategoryPosterScreen(kid)
                end if

```

to

```auto
 
                displaySubCategoryScreen()

```

where displaySubCategoryScreen() is defined in your newly created subCategoryFeed.brs.

–Kevin

---

<div class="post-metadata">

**Author:** ![saravanainfo](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@saravanainfo](https://forum.developer.roku.com/u/saravanainfo)\
**Post date:** [December 21, 2011, 8:49pm UTC](https://forum.developer.roku.com/t/processing-xml-sub-categories/1365/5 "2011-12-21T20:49:31Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![luke823](https://avatars.discourse-cdn.com/v4/letter/l/22d042/32.png) [@luke823](https://forum.developer.roku.com/u/luke823)\
**Post date:** [March 10, 2013, 8:13pm UTC](https://forum.developer.roku.com/t/processing-xml-sub-categories/1365/6 "2013-03-10T20:13:04Z")

</div>

is this still the most current information on sub-categories, or can it be done now without having to write bright script?

---

<div class="post-metadata">

**Author:** ![b14d3](https://avatars.discourse-cdn.com/v4/letter/b/c6cbf5/32.png) [@b14d3](https://forum.developer.roku.com/u/b14d3)\
**Post date:** [March 11, 2013, 1:54pm UTC](https://forum.developer.roku.com/t/processing-xml-sub-categories/1365/7 "2013-03-11T13:54:31Z")

</div>

> “saravanainfo” wrote:
> 
> conn.UrlPrefix = “pkg:/XML”

The xml should be in an internet-accessible URL, not contained in the package. [http://rokudev.roku.com](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.

---

<div class="post-metadata">

**Author:** ![Blackhawk](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@Blackhawk](https://forum.developer.roku.com/u/Blackhawk)\
**Post date:** [October 12, 2016, 8:42pm UTC](https://forum.developer.roku.com/t/processing-xml-sub-categories/1365/8 "2016-10-12T20:42:19Z")

</div>

Like this?

```auto
conn.UrlPrefix   = "rokudev.roku.com/Channel/xml/shows"

    conn.UrlCategoryFeed = conn.UrlPrefix + "/Shows.xml"

```
