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: 
lbell
Visitor

Cant parse feed

I've validated the xml files, but I keep getting these error messages

Compiled successfully
------ Running ------
created feed connection for https://drive.google.com/file/d/0B_qjht-B80ceNC11OGs3WG9GeDA/edit?usp=sharing
url: https://drive.google.com/file/d/0B_qjht-B80ceNC11OGs3WG9GeDA/edit?usp=sharing
Took: 53ms
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/feedcategory.brs(38)
038:     for each category in categories.kids
Backtrace:
Function get_category_names(categories As Object) As Dynamic
   file/line: /tmp/plugin/EGAAAAR4ZpT6/pkg:/source/feedcategory.brs(38)
Function initcategorylist() As Void
   file/line: /tmp/plugin/EGAAAAR4ZpT6/pkg:/source/Mainmenu.brs(134)
Function showhomescreen(screen As Dynamic) As Integer
   file/line: /tmp/plugin/EGAAAAR4ZpT6/pkg:/source/Mainmenu.brs(39)
Function main() As Void
   file/line: /tmp/plugin/EGAAAAR4ZpT6/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>


Any ideas? I tried hosting it on Google drive and Dropbox but I get the same errors for both.
0 Kudos
8 REPLIES 8
belltown
Roku Guru

Re: Cant parse feed

for each category in categories
0 Kudos
adrianc1982
Visitor

Re: Cant parse feed

everytime you open a while, an inf and a for or for each

you have to close it.

try adding a "end for" in line 41 and replace it with the next you have, let me know if that solved your problem.

And actually the compiler tells you the error.. which in this case is: "Syntax Error."

your syntaxis is off, thats because you didnt close a for loop.
0 Kudos
destruk
Streaming Star

Re: Cant parse feed

"Next" is the same as "End For", so it was in the top code posting for the thread.
If categories.kids has something in it then it ought to be ok there...
0 Kudos
adrianc1982
Visitor

Re: Cant parse feed

"destruk" wrote:
"Next" is the same as "End For", so it was in the top code posting for the thread.
If categories.kids has something in it then it ought to be ok there...


wouldnt hurt to try the end for anyway hehehe

i didnt know about the next, and i try not to learn specifics about a language like next that i knows its only particular for brightscript.

end for on the other hand i just see it in my mind as a { } hehehe
0 Kudos
belltown
Roku Guru

Re: Cant parse feed

"destruk" wrote:

If categories.kids has something in it then it ought to be ok there...


It doesn't.
0 Kudos
EnTerr
Roku Guru

Re: Cant parse feed

Terse as he was, belltown is correct.
The exact error message is not helpful - but I am fairly sure categories is invalid (to test after this error, in console just type `? type(categories), categories` ).

Luckily we have the reason in console dump too - @lbell, instead of
https://drive.google.com/file/d/0B_qjht ... sp=sharing
try using
https://docs.google.com/uc?authuser=0&i ... t=download
Instead of the original xml file, you were getting some html page to edit the file
0 Kudos
belltown
Roku Guru

Re: Cant parse feed

Yes, at least 3 separate issues here:

1. The xml would not parse because of what EnTerr said. You can see from the debug output that 'categories' is invalid:


Local Variables:
categories &h0010 bsc:roInvalid, refcnt=1

2. Even if it did parse, the 'categories' element contains no 'kids' children, only 'category' children, which is why you need to replace:


for each category in categories.kids

with


for each category in categories.category

(slight correction from what I said in my first reply).

3. Also, since 'title' is an attribute of 'category', not a child element, you cannot get its text from category.Title; you have to use category@title. Even if it were a child element, you still couldn't get the text using category.Title; in that case you'd need category.Title.GetText ()
0 Kudos
lbell
Visitor

Re: Cant parse feed

My hosting was bad. My friend let me use his website to host the xml file and everything worked! I didn't have to change the code at all!
Thanks guys!
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.