Your Digital Media Has Never Looked So Good

 
Banta67
Topic Author
Posts: 18
Joined: Mon Aug 18, 2008 12:00 pm

XML - Categories/Levels Question

Fri Mar 12, 2010 7:58 am

Hello,

I am trying to develop a channel based on the VIDEOPLAYER Sample.

Currently, in the sample categories.xml, each category has <categoryLeaf> nodes, as such.....

<category title="Technology" description="TED Talks on Technology" sd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/TED_Technology.png" hd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/TED_Technology.png">
<categoryLeaf title="The Mind" description="" feed="http://rokudev.roku.com/rokudev/examples/videoplayer/xml/themind.xml"/>
<categoryLeaf title="Global Issues" description="" feed="http://rokudev.roku.com/rokudev/examples/videoplayer/xml/globalissues.xml" />
</category>


My question is regarding categories that don't need leafs. How could I just select a category and go directly to the associated feed without the need to select a leaf?

Would this work?

<category title="Technology" description="TED Talks on Technology" sd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/TED_Technology.png" hd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/TED_Technology.png" feed="http://rokudev.roku.com/rokudev/examples/videoplayer/xml/themind.xml"/>
<category title="Entertainment" description="TED Talks on Entertainment" sd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/TED_Entertainment.png" hd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/TED_Entertainment.png">
<categoryLeaf title="Music" description="" feed="http://rokudev.roku.com/rokudev/examples/videoplayer/xml/music.xml" />
<categoryLeaf title="Inspiration" description="" feed="http://rokudev.roku.com/rokudev/examples/videoplayer/xml/inspiration.xml" />
</category>


In the case above, the FEED attribute is moved out of the <categoryLeaf> node and placed in the parent <category> node. If the user selects Technology, they are taken directly to the themind.xml feed. However if they selected Entertainment, they would have to choose a leaf to further drill down.
Make sense? Would this work? If not, can you explain what it would entail to make this work?

Thank you for your help.
Banta
 
User avatar
RokuKevin
Roku Engineering
Posts: 796
Joined: Tue Sep 22, 2009 2:29 pm

Re: XML - Categories/Levels Question

Fri Mar 12, 2010 6:36 pm

For a feed of the size in the videoplayer sample app, it would probably make sense to have just one .xml file that contained all the nodes for every category. The sample is broken up into several different feeds because we feel it would be a good "best practice" to break up your feeds into more manageable chunks. Very large feeds are expensive to download, take up a lot of memory on the box and take a long time to parse. That's why we encourage breaking up your feeds.

That said, you can always change the way the sample app is parsing the feeds if you want to combine them into one feed for you application. Just change the feed parsing code in categoryFeed.brs and showFeed.brs

--Kevin
 
cgerrish
Posts: 24
Joined: Mon May 17, 2010 4:59 pm

Re: XML - Categories/Levels Question

Sat Sep 04, 2010 11:22 am

Did you figure out how to skip the category leaf section for certain categories and go straight to the feed? If so any hints you would like to share would be awesome.
 
joetesta
Posts: 790
Joined: Wed Apr 20, 2011 11:48 am

Re: XML - Categories/Levels Question

Thu Apr 21, 2011 3:36 pm

I'm also trying to figure out how to eliminate the "leafs" (or at least the extra down click required to go from the leaf name to the list of shows)

Just change the feed parsing code in categoryFeed.brs and showFeed.brs


he makes it sound so easy :) I'm looking at that code now, scratching my head... well I broke everything - starting over with fresh example source for round 2...

maybe it will be easier to have just 1 category and use the leafs as my categories, then the user would only have to do the extra click in the beginning.
aspiring
 
joetesta
Posts: 790
Joined: Wed Apr 20, 2011 11:48 am

Re: XML - Categories/Levels Question

Fri Apr 22, 2011 10:36 am

Traversing: 17ms
showHomeScreen | msg =  | index =  1
showHomeScreen | msg =  | index =  1
device already linked, skipping registration process
list item selected | index =  1
invalid parameter of type roInvalid for <ROT:roInvalid> is not roAssociativeArra
y in function initShowFeedConnection
Current Function:
125: Function getShowsForCategoryItem(category As Object, item As Integer) As Ob
ject
126:
127:     if validateParam(category, "roAssociativeArray", "getCategoryList") = f
alse return invalid
128:
129:     conn = InitShowFeedConnection(category.kids[item])
130:     'conn = InitShowFeedConnection(category)
131:     showList = conn.LoadShowFeed(conn)
132:     return showList
133:
134: End Function
/tmp/plugin/HHAAAAgTifHi/pkg:/source/appPosterScreen.brs(131): runtime error f4:
 Member function not found in BrightScript Component or interface.

131:     showList = conn.LoadShowFeed(conn)

Backtrace:
Function getshowsforcategoryitem(category As Object, item As Integer) As Object
Function showposterscreen(screen As Object, category As Object) As Integer
Function displaycategoryposterscreen(category As Object) As Untyped
Function showhomescreen(screen As Untyped) As Integer
Function main() As Void

Local Variables:
category &h16 bsc:roAssociativeArray, refcnt=5
item     &h02 Integer val:0
global   &h07 rotINTERFACE:ifGlobal
m        &h06 bsc:roAssociativeArray, refcnt=6
conn     &h16 bsc:roInvalid, refcnt=1
showlist &h30 Untyped val:Uninitialized
BrightScript Debugger> ------ Running ------
Looking for conn: http://192.168.1.224/categories.xml
created feed connection for http://192.168.1.224/categories.xml
url: http://192.168.1.224/categories.xml
Took: 28ms
Parse Took: 3ms
begin category node parsing
number of categories: 4
ParseCategoryNode: banner_ad
ParseCategoryNode skip: banner_ad
parse returned no child node
ParseCategoryNode: category
category: Newly Added | Movies that have been recently added
added new child node
ParseCategoryNode: category
category: Big News | Movies that feature news
added new child node
ParseCategoryNode: category
category: College | Movies about what it's like to go to college
added new child node
Traversing: 23ms
showHomeScreen | msg =  | index =  1
showHomeScreen | msg =  | index =  1
device already linked, skipping registration process
list item selected | index =  1
invalid parameter of type roInvalid for <ROT:roInvalid> is not roAssociativeArra
y in function initShowFeedConnection
BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Current Function:
125: Function getShowsForCategoryItem(category As Object, item As Integer) As Ob
ject
126:
127:     if validateParam(category, "roAssociativeArray", "getCategoryList") = f
alse return invalid
128:
129:     conn = InitShowFeedConnection(category.kids[item])
130:     'conn = InitShowFeedConnection(category)
131:     showList = conn.LoadShowFeed(conn)
132:     return showList
133:
134: End Function
/tmp/plugin/JHAAAAhHGxgy/pkg:/source/appPosterScreen.brs(131): runtime error f4:
 Member function not found in BrightScript Component or interface.

131:     showList = conn.LoadShowFeed(conn)

Backtrace:
Function getshowsforcategoryitem(category As Object, item As Integer) As Object
Function showposterscreen(screen As Object, category As Object) As Integer
Function displaycategoryposterscreen(category As Object) As Untyped
Function showhomescreen(screen As Untyped) As Integer
Function main() As Void

Local Variables:
category &h16 bsc:roAssociativeArray, refcnt=5
item     &h02 Integer val:0
global   &h07 rotINTERFACE:ifGlobal
m        &h06 bsc:roAssociativeArray, refcnt=6
conn     &h16 bsc:roInvalid, refcnt=1
showlist &h30 Untyped val:Uninitialized
BrightScript Debugger>
Last edited by joetesta on Fri Apr 22, 2011 12:45 pm, edited 2 times in total.
aspiring
 
dynamitemedia
Posts: 577
Joined: Wed Feb 03, 2010 7:49 am

Re: XML - Categories/Levels Question

Fri Apr 22, 2011 12:24 pm

I can tell you from experience, that my first ever time coding with brightscript or really anything other than PHP :roll: , that you picked the hardest example to tackle your first time around.

is it that you just don't like the function of click down? or do you only have one category?

you don't need to use the category leafs if you don't want anyways. show us what your xml looks like, maybe one of us can help you out
Twitter: iptvmyway facebook: iptvmyay
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
 
joetesta
Posts: 790
Joined: Wed Apr 20, 2011 11:48 am

Re: XML - Categories/Levels Question

Fri Apr 22, 2011 12:49 pm

thanks dynamitemedia!

I got it to work! My last change was adding this line 'o.Feed = xml@feed' in CategoryFeed.brs to Function ParseCategoryNode just before this line 'elseif xml.GetName() = "categoryLeaf" then'

is it that you just don't like the function of click down? or do you only have one category?
you don't need to use the category leafs if you don't want anyways.


We have multiple categories, but not subcategories (leafs). Those subcategories are overkill for what we have, and going with a single subcategory in each category seemed pointless, because then the user has to click an extra time to start scrolling through the options. Maybe I will reconsider that.

Figuring out how to eliminate the subcategories took me about 4 hours of following the functions/ subroutines from file to file and adding debug code to see what was happening along the way. I don't feel any smarter but maybe my next task will go easier, after having survived this challenge.
aspiring
 
dynamitemedia
Posts: 577
Joined: Wed Feb 03, 2010 7:49 am

Re: XML - Categories/Levels Question

Fri Apr 22, 2011 1:23 pm

i see what your saying, yes the video player is tough, its like the complete package but missing the essentials to make it work for a newbie, i know i went thru it.

to make it worse is that its spread out so many pages and not sure what connects to what in the flow at first, but once you do its gets easier.
Twitter: iptvmyway facebook: iptvmyay
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
 
ChrisDotson
Posts: 13
Joined: Thu Nov 04, 2010 11:17 am

Re: XML - Categories/Levels Question

Wed May 11, 2011 1:14 pm

joetesta wrote:
I got it to work! My last change was adding this line 'o.Feed = xml@feed' in CategoryFeed.brs to Function ParseCategoryNode just before this line 'elseif xml.GetName() = "categoryLeaf" then'


Any chance you would share all of the changes you made? I'm trying to do the exact same thing and having the worst time getting it to work.
 
joetesta
Posts: 790
Joined: Wed Apr 20, 2011 11:48 am

Re: XML - Categories/Levels Question

Thu Oct 27, 2011 3:23 pm

Wow apologies for the extremely late reply, I've been on another project for months and just came back to look at roku again this week.

Well here goes, I hope you've figured it out by now but maybe this will help someone else!

in appDetailSceen.brs Replace:
Function preShowDetailScreen(breadA=invalid, breadB=invalid) As Object
    port=CreateObject("roMessagePort")
    screen = CreateObject("roSpringboardScreen")
    screen.SetDescriptionStyle("video")
    screen.SetMessagePort(port)
    if breadA<>invalid and breadB<>invalid then
        screen.SetBreadcrumbText(breadA, breadB)
    end if

with
Function preShowDetailScreen(breadA=invalid) As Object
    port=CreateObject("roMessagePort")
    screen = CreateObject("roSpringboardScreen")
    screen.SetDescriptionStyle("video")
    screen.SetMessagePort(port)


in appPosterScreen.brs change
    screen = preShowDetailScreen(category.Title, category.kids[m.curCategory].Title)
    showIndex = showDetailScreen(screen, shows, showIndex)

to
    'screen = preShowDetailScreen(category.Title, category.kids[m.curCategory].Title)
    screen = preShowDetailScreen(category.Title)
    showIndex = showDetailScreen(screen, shows, showIndex)


and also in appPosterScreen.brs change this
    categoryList = CreateObject("roArray", 100, true)
    for each subCategory in topCategory.Kids
        categoryList.Push(subcategory.Title)
    next
    return categoryList

to this
    categoryList = CreateObject("roArray", 100, true)
    categoryList = topCategory

    return categoryList


and also in appPosterScreen.brs change this
    conn = InitShowFeedConnection(category.kids[item])

to this
    conn = InitShowFeedConnection(category)


and in CategoryFeed.brs
        o.HDPosterURL = xml@hd_img

to this
        o.HDPosterURL = xml@hd_img
        o.Feed = xml@feed


and also in CategoryFeed.brs change this
           kid.HDPosterURL = xml@hd_img
            o.AddKid(kid)

to
            kid.HDPosterURL = xml@hd_img
            kid.Feed = e@feed
            o.AddKid(kid)


I *think* that's it, I apologize if anything is extraneous or incorrect, it's been a while!!
aspiring
 
koshermetal
Posts: 18
Joined: Sat Oct 29, 2011 1:13 am
Location: United States
Contact:

Re: XML - Categories/Levels Question

Sat Oct 29, 2011 1:43 am

I'm not sure if this is the right place for this, I'm sort of a noob but I'd like to think I have a brain :)

I'm using the videoplayer example files and seem to have it all figured out...except for the xml aspect (from what I gather). I am able to install the channel, but nothing happens when selected. My custom image shows fine though, since I edited the manifest file to point to my custom images, etc.

When debugging I get the following (amongst other stuff, I can post the entire thing if needed):
Syntax Error. (runtime error &h02) in .../pkg:/source/categoryFeed.brs(38)

along with
created feed connection for pkg:/xml/categories.xml
url: pkg:/xml/categories.xml
Took: 856ms
Can't parse feed


In the categoryfeed.brs file I have:
conn.UrlPrefix   = "pkg:/xml"
    conn.UrlCategoryFeed = conn.UrlPrefix + "/categories.xml"


My categories.xml file looks like this, there is only one "categoryleaf" currently but I plan to add more and re-package the channel as I update: (I replaced my actual tltle with "TITLE" & description with "DESC" for this post and didn't put the entire URL of the images, etc. - just wanted to show the structure):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>
<banner_ad
sd_img="http://dl.dropbox.com...." hd_img="http://dl.dropbox.com......"/>
<category title="Videos" description="DESC"
sd_img="http://dl.dropbox.com..."
hd_img="http://dl.dropbox.com....">
<categoryLeaf title="TITLE" description="DESC" feed="pkg:/xml/5lcl.xml"/>
</category>
</categories>



Is there something I'm missing? BTW...I'm using the SDK v29 that was provided on the dev site. Windows 7 w/ PuTTY as my telnet terminal. I have a Roku 2 XD Software v4.1

Thanks in advance for your help guys!
Free 24/7 Metal radio via web or smartphone
www.koshermetal.com
 
renojim
** Valued Community Member **
Posts: 3490
Joined: Mon Feb 15, 2010 1:35 pm

Re: XML - Categories/Levels Question

Sat Oct 29, 2011 1:46 pm

RokuChris posted a good link for an XML validator: http://www.w3schools.com/xml/xml_validator.asp

Your XML seems to be fine, so I'm wondering if there's something wrong with what you've replaced with the ellipses.

Edit: It's not the XML. You can't do an roUrlTransfer from local storage. A quick hack (and it is a hack) is to replace:
rsp = http.GetToStringWithRetry()
with
rsp = ReadAsciiFile(http.Http.GetUrl())
in categoryFeed.brs.


-JT
Last edited by renojim on Sat Oct 29, 2011 2:26 pm, edited 1 time in total.
 
koshermetal
Posts: 18
Joined: Sat Oct 29, 2011 1:13 am
Location: United States
Contact:

Re: XML - Categories/Levels Question

Sat Oct 29, 2011 2:11 pm

Well...there was an error coincidentally in the categories.xml file - there was an ampersand in the description, so thanks for helping me fix that. However...I still get syntax and parse errors. I validated both xml files in the xml directory and there are no errors. Below is the entire copy from the debugger.

34: Function get_category_names(categories As Object) As Dynamic
035:
036:     categoryNames = CreateObject("roArray", 100, true)
037:
038:     for each category in categories.kids
039:         'print category.Title
040:         categoryNames.Push(category.Title)
041:     next
042:
043:     return categoryNames
044:
045: End Function
Syntax Error. (runtime error &h02) in .../pkg:/source/categoryFeed.brs(38)

038:     for each category in categories.kids
Backtrace:
Function get_category_names(categories As <uninitialized>) As
   file/line: /tmp/plugin/LDAAAA4Iq.../pkg:/source/categoryFeed.brs(38)
Function initcategorylist() As
   file/line: /tmp/plugin/LDAAAA4Iqp1v/pkg:/source/appHomeScreen.brs(112)
Function showhomescreen(screen As ) As Integer
   file/line: /tmp/plugin/LDAAAA4Iqp1v/pkg:/source/appHomeScreen.brs(39)
Function main() As
   file/line: /tmp/plugin/LDAAAA4Iqp1v/pkg:/source/appMain.brs(20)

Local Variables:
categories &h0010 bsc:roInvalid, refcnt=1
global   &h0020 rotINTERFACE:ifGlobal
m        &h0010 bsc:roAssociativeArray, refcnt=3
categorynames &h0010 bsc:roArray, refcnt=1
category &h0000 <uninitialized> val:Uninitialized
BrightScript Debugger> ------ Running ------
created feed connection for pkg:/xml/categories.xml
url: pkg:/xml/categories.xml
Took: 867ms
Can't parse feed
BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Current Function:
034: Function get_category_names(categories As Object) As Dynamic
035:
036:     categoryNames = CreateObject("roArray", 100, true)
037:
038:     for each category in categories.kids
039:         'print category.Title
040:         categoryNames.Push(category.Title)
041:     next
042:
043:     return categoryNames
044:
045: End Function
Syntax Error. (runtime error &h02) in .../pkg:/source/categoryFeed.brs(38)

038:     for each category in categories.kids
Backtrace:
Function get_category_names(categories As <uninitialized>) As
   file/line: /tmp/plugin/NDAAAAdIW.../pkg:/source/categoryFeed.brs(38)
Function initcategorylist() As
   file/line: /tmp/plugin/NDAAAAdIWH28/pkg:/source/appHomeScreen.brs(112)
Function showhomescreen(screen As ) As Integer
   file/line: /tmp/plugin/NDAAAAdIWH28/pkg:/source/appHomeScreen.brs(39)
Function main() As
   file/line: /tmp/plugin/NDAAAAdIWH28/pkg:/source/appMain.brs(20)

Local Variables:
categories &h0010 bsc:roInvalid, refcnt=1
global   &h0020 rotINTERFACE:ifGlobal
m        &h0010 bsc:roAssociativeArray, refcnt=3
categorynames &h0010 bsc:roArray, refcnt=1
category &h0000 <uninitialized> val:Uninitialized
BrightScript Debugger> BrightScript Debugger> BrightScript Debugger> ------ Running ------
created feed connection for pkg:/xml/categories.xml
url: pkg:/xml/categories.xml
Took: 54ms
Can't parse feed
Current Function:
034: Function get_category_names(categories As Object) As Dynamic
035:
036:     categoryNames = CreateObject("roArray", 100, true)
037:
038:     for each category in categories.kids
039:         'print category.Title
040:         categoryNames.Push(category.Title)
041:     next
042:
043:     return categoryNames
044:
045: End Function
Syntax Error. (runtime error &h02) in .../pkg:/source/categoryFeed.brs(38)

038:     for each category in categories.kids
Backtrace:
Function get_category_names(categories As <uninitialized>) As
   file/line: /tmp/plugin/NDAAAAdIW.../pkg:/source/categoryFeed.brs(38)
Function initcategorylist() As
   file/line: /tmp/plugin/NDAAAAdIWH28/pkg:/source/appHomeScreen.brs(112)
Function showhomescreen(screen As ) As Integer
   file/line: /tmp/plugin/NDAAAAdIWH28/pkg:/source/appHomeScreen.brs(39)
Function main() As
   file/line: /tmp/plugin/NDAAAAdIWH28/pkg:/source/appMain.brs(20)

Local Variables:
categories &h0010 bsc:roInvalid, refcnt=1
global   &h0020 rotINTERFACE:ifGlobal
m        &h0010 bsc:roAssociativeArray, refcnt=3
categorynames &h0010 bsc:roArray, refcnt=1
category &h0000 <uninitialized> val:Uninitialized
BrightScript Debugger>


Here is what the categoryfeed.brs file looks like, since it seems to be of relevance.
Function InitCategoryFeedConnection() As Object

    conn = CreateObject("roAssociativeArray")

    conn.UrlPrefix   = "pkg:/xml"
    conn.UrlCategoryFeed = conn.UrlPrefix + "/categories.xml"

    conn.Timer = CreateObject("roTimespan")

    conn.LoadCategoryFeed    = load_category_feed
    conn.GetCategoryNames    = get_category_names

    print "created feed connection for " + conn.UrlCategoryFeed
    return conn

End Function

'*********************************************************
'** Create an array of names representing the children
'** for the current list of categories. This is useful
'** for filling in the filter banner with the names of
'** all the categories at the next level in the hierarchy
'*********************************************************
Function get_category_names(categories As Object) As Dynamic

    categoryNames = CreateObject("roArray", 100, true)

    for each category in categories.kids
        'print category.Title
        categoryNames.Push(category.Title)
    next

    return categoryNames

End Function


'******************************************************************
'** Given a connection object for a category feed, fetch,
'** parse and build the tree for the feed.  the results are
'** stored hierarchically with parent/child relationships
'** with a single default node named Root at the root of the tree
'******************************************************************
Function load_category_feed(conn As Object) As Dynamic

    http = NewHttp(conn.UrlCategoryFeed)

    Dbg("url: ", http.Http.GetUrl())

    m.Timer.Mark()
    rsp = http.GetToStringWithRetry()
    Dbg("Took: ", m.Timer)

    m.Timer.Mark()
    xml=CreateObject("roXMLElement")
    if not xml.Parse(rsp) then
         print "Can't parse feed"
        return invalid
    endif
    Dbg("Parse Took: ", m.Timer)

    m.Timer.Mark()
    if xml.category = invalid then
        print "no categories tag"
        return invalid
    endif

    if islist(xml.category) = false then
        print "invalid feed body"
        return invalid
    endif

    if xml.category[0].GetName() <> "category" then
        print "no initial category tag"
        return invalid
    endif

    topNode = MakeEmptyCatNode()
    topNode.Title = "root"
    topNode.isapphome = true

    print "begin category node parsing"

    categories = xml.GetChildElements()
    print "number of categories: " + itostr(categories.Count())
    for each e in categories
        o = ParseCategoryNode(e)
        if o <> invalid then
            topNode.AddKid(o)
            print "added new child node"
        else
            print "parse returned no child node"
        endif
    next
    Dbg("Traversing: ", m.Timer)

    return topNode

End Function

'******************************************************
'MakeEmptyCatNode - use to create top node in the tree
'******************************************************
Function MakeEmptyCatNode() As Object
    return init_category_item()
End Function


'***********************************************************
'Given the xml element to an <Category> tag in the category
'feed, walk it and return the top level node to its tree
'***********************************************************
Function ParseCategoryNode(xml As Object) As dynamic
    o = init_category_item()

    print "ParseCategoryNode: " + xml.GetName()
    'PrintXML(xml, 5)

    'parse the curent node to determine the type. everything except
    'special categories are considered normal, others have unique types
    if xml.GetName() = "category" then
        print "category: " + xml@title + " | " + xml@description
        o.Type = "normal"
        o.Title = xml@title
        o.Description = xml@Description
        o.ShortDescriptionLine1 = xml@Title
        o.ShortDescriptionLine2 = xml@Description
        o.SDPosterURL = xml@sd_img
        o.HDPosterURL = xml@hd_img
    elseif xml.GetName() = "categoryLeaf" then
        o.Type = "normal"
    elseif xml.GetName() = "specialCategory" then
        if invalid <> xml.GetAttributes() then
            for each a in xml.GetAttributes()
                if a = "type" then
                    o.Type = xml.GetAttributes()[a]
                    print "specialCategory: " + xml@type + "|" + xml@title + " | " + xml@description
                    o.Title = xml@title
                    o.Description = xml@Description
                    o.ShortDescriptionLine1 = xml@Title
                    o.ShortDescriptionLine2 = xml@Description
                    o.SDPosterURL = xml@sd_img
                    o.HDPosterURL = xml@hd_img
                endif
            next
        endif
    else
        print "ParseCategoryNode skip: " + xml.GetName()
        return invalid
    endif

    'only continue processing if we are dealing with a known type
    'if new types are supported, make sure to add them to the list
    'and parse them correctly further downstream in the parser
    while true
        if o.Type = "normal" exit while
        if o.Type = "special_category" exit while
        print "ParseCategoryNode unrecognized feed type"
        return invalid
    end while

    'get the list of child nodes and recursed
    'through everything under the current node
    for each e in xml.GetBody()
        name = e.GetName()
        if name = "category" then
            print "category: " + e@title + " [" + e@description + "]"
            kid = ParseCategoryNode(e)
            kid.Title = e@title
            kid.Description = e@Description
            kid.ShortDescriptionLine1 = xml@Description
            kid.SDPosterURL = xml@sd_img
            kid.HDPosterURL = xml@hd_img
            o.AddKid(kid)
        elseif name = "categoryLeaf" then
            print "categoryLeaf: " + e@title + " [" + e@description + "]"
            kid = ParseCategoryNode(e)
            kid.Title = e@title
            kid.Description = e@Description
            kid.Feed = e@feed
            o.AddKid(kid)
        elseif name = "specialCategory" then
            print "specialCategory: " + e@title + " [" + e@description + "]"
            kid = ParseCategoryNode(e)
            kid.Title = e@title
            kid.Description = e@Description
            kid.sd_img = e@sd_img
            kid.hd_img = e@hd_img
            kid.Feed = e@feed
            o.AddKid(kid)
        endif
    next

    return o
End Function


'******************************************************
'Initialize a Category Item
'******************************************************
Function init_category_item() As Object
    o = CreateObject("roAssociativeArray")
    o.Title       = ""
    o.Type        = "normal"
    o.Description = ""
    o.Kids        = CreateObject("roArray", 100, true)
    o.Parent      = invalid
    o.Feed        = ""
    o.IsLeaf      = cn_is_leaf
    o.AddKid      = cn_add_kid
    return o
End Function


'********************************************************
'** Helper function for each node, returns true/false
'** indicating that this node is a leaf node in the tree
'********************************************************
Function cn_is_leaf() As Boolean
    if m.Kids.Count() > 0 return true
    if m.Feed <> "" return false
    return true
End Function


'*********************************************************
'** Helper function for each node in the tree to add a
'** new node as a child to this node.
'*********************************************************
Sub cn_add_kid(kid As Object)
    if kid = invalid then
        print "skipping: attempt to add invalid kid failed"
        return
     endif
   
    kid.Parent = m
    m.Kids.Push(kid)
End Sub


Thanks again for your help!
Free 24/7 Metal radio via web or smartphone
www.koshermetal.com
 
renojim
** Valued Community Member **
Posts: 3490
Joined: Mon Feb 15, 2010 1:35 pm

Re: XML - Categories/Levels Question

Sat Oct 29, 2011 2:26 pm

See my edited post above.

-JT
 
koshermetal
Posts: 18
Joined: Sat Oct 29, 2011 1:13 am
Location: United States
Contact:

Re: XML - Categories/Levels Question

Sat Oct 29, 2011 4:30 pm

Thanks JT!

That hack definitely did the trick, now I can start focusing on making sure it's how I want and make the necessary tweaks. You rule man!

BUT...since you say that it's a "hack", does that mean I may run into problems when I decide to submit it as a public channel? Meaning it won't get approved due to the "hack" code?

Thanks!
Free 24/7 Metal radio via web or smartphone
www.koshermetal.com

Who is online

Users browsing this forum: No registered users and 15 guests