jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2010
01:22 AM
Re: parsing XML question
Good Night, thanks for all the help!
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
renojim
Community Streaming Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2010
07:11 AM
Re: parsing XML question
"TheEndless" wrote:
In your If statement, you should be checking Count() on xmlFileCount, not on FileCountString.If xmlFileCount <> invalid And xmlFileCount.Count() > 0 Then
Someone correct me if I'm wrong, but I believe that statement will crash to the debugger if xmlFileCount is invalid since both parts of the "if" are always evaluated.
-JT
Roku Community Streaming Expert
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2010
08:33 AM
Re: parsing XML question
"renojim" wrote:"TheEndless" wrote:
In your If statement, you should be checking Count() on xmlFileCount, not on FileCountString.If xmlFileCount <> invalid And xmlFileCount.Count() > 0 Then
Someone correct me if I'm wrong, but I believe that statement will crash to the debugger if xmlFileCount is invalid since both parts of the "if" are always evaluated.
-JT
That's not been my experience. In all of my testing, if the first evaluation fails, the second isn't evaluated.
I just tested again, and the following code prints "invalid"..
test = invalid
If test <> invalid And test.Count() > 0 Then
print "test"
Else
print "invalid"
End If
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
renojim
Community Streaming Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2010
10:00 AM
Re: parsing XML question
Thanks for checking. I thought I saw it crash in the past, but it was a while ago and I could be misremembering.
-JT
-JT
Roku Community Streaming Expert
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.
jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2010
12:22 PM
Re: parsing XML question
"TheEndless" wrote:
In your If statement, you should be checking Count() on xmlFileCount, not on FileCountString.If xmlFileCount <> invalid And xmlFileCount.Count() > 0 Then
Hate to abandon you, but it's 4am here, and I've got a 5 year old's party to go to in a few hours, so I need to hit the sack. Good luck!
Yeah, that fixed it. Last night (this morning, really, about 5am) I got all the parsing working properly. Now I'm trying to figure out how to get the audio player to play the urls that are returned. I'll post any questions on that in a separate thread. Really, thanks again for helping me wrap my head around all these concepts!
- Joel
-
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
dynamitemedia
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2010
10:28 AM
Re: parsing XML question
ok guys i am gonna try to understand this.
i want to stick with the way i know in grabbing a XML file which is
I am not at home to test but will this give me the same results or will this only bring back and display one "song"?
if it doesn't bring back more than one "song" what do i need to do to make this to display the same amount as from the xml file.
i want to stick with the way i know in grabbing a XML file which is
m.UrlGetMp3Info = m.UrlBase + "/Mp3Playlist.php"
http = NewHttp(m.UrlGetMp3Info)
rsp = http.Http.GetToString()
xml = CreateObject("roXMLElement")
print "GOT: " + rsp
print "Reason: " + http.Http.GetFailureReason()
if not xml.Parse(rsp) then
print "Can't parse response"
ShowConnectionFailed()
return ""
end if
if xml.GetName() <> "result"
Dbg("Bad register response: ", xml.GetName())
ShowConnectionFailed()
return ""
end if
if islist(xml.GetBody()) = false then
Dbg("No Song information available")
ShowConnectionFailed()
return ""
end if
'handle validation of response fields
for each e in xml.GetBody()
if e.GetName() = "title" then
title = e.GetBody()
end if
if e.GetName() = "author" then
author = e.GetBody()
end if
if e.GetName() = "desc" then
desc = e.GetBody()
end if
if e.GetName() = "url" then
url = e.GetBody()
end if
if e.GetName() = "image" then
image = e.GetBody()
end if
next
song = CreateSong(title, desc, author, "mp3", url, image)
aa.posteritems.push(song)
I am not at home to test but will this give me the same results or will this only bring back and display one "song"?
if it doesn't bring back more than one "song" what do i need to do to make this to display the same amount as from the xml file.
Twitter: iptvmyway facebook: iptvmyay
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
dynamitemedia
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2010
11:40 AM
Re: parsing XML question
Ok i got home and tested this...
i get the same error when i have the "next" before or after "song = "
It doesn't say which variable but i would assume all of them are incorrect
012: m.UrlGetMp3Info = m.UrlBase + "/FAN/xml/mp3Playlist.php"
013:
014: http = NewHttp(m.UrlGetMp3Info)
015: http.AddParam("token", token)
016:
017: rsp = http.Http.GetToString()
018: xml = CreateObject("roXMLElement")
019: print "GOT: " + rsp
020: print "Reason: " + http.Http.GetFailureReason()
021:
022: if not xml.Parse(rsp) then
023: print "Can't parse response"
024: ShowConnectionFailed()
025: return ""
026: end if
027:
028: if xml.GetName() <> "feed"
029: Dbg("Bad register response: ", xml.GetName())
030: ShowConnectionFailed()
031: return ""
032: end if
033:
034: if islist(xml.GetBody()) = false then
035: Dbg("No registration information available")
036: ShowConnectionFailed()
037: return ""
038: end if
039:
040: 'handle validation of response fields
041: for each e in xml.GetBody()
042: if e.GetName() = "title" then
043: title = e.GetBody()
044: end if
045: if e.GetName() = "contentType" then
046: author = e.GetBody()
047: end if
048: if e.GetName() = "synopsis" then
049: desc = e.GetBody()
050: end if
051: if e.GetName() = "streamUrl" then
052: url = e.GetBody()
053: end if
054: if e.GetName() = "image" then
055: image = e.GetBody()
056: end if
057:
058:
059:
060: song = CreateSong(title, desc, author, "mp3", url, image)
061: aa.posteritems.push(song)
062:
063: next
064:
065: return aa
066: End Function
/tmp/plugin/AFAAAAPEnNrs/pkg:/source/testMp3.brs(60): runtime error e9: Use of uninitialized variable
060: song = CreateSong(title, desc, author, "mp3", url, image)
i get the same error when i have the "next" before or after "song = "
It doesn't say which variable but i would assume all of them are incorrect
Twitter: iptvmyway facebook: iptvmyay
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
dynamitemedia
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2010
12:41 PM
Re: parsing XML question
Ok i have looked over all sorts of samples in the examples and some that have been sent to me.
and i dont see what i am missing here...
i am not getting any errors from the XML and this code works in all areas of my code.
why is it saying the variable is uninitialized? and most importantly what variable is it talking about?
and i dont see what i am missing here...
i am not getting any errors from the XML and this code works in all areas of my code.
why is it saying the variable is uninitialized? and most importantly what variable is it talking about?
Twitter: iptvmyway facebook: iptvmyay
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2010
12:49 PM
Re: parsing XML question
You're getting the "unitialized" error because you're not getting the value of each of "title", "desc", "author", "url" or "image" in the current loop. "if e.GetName()" is checking the current element, so it's only going to be one of the five, but you're trying to pass all of them to CreateSong(), so four of the five won't be initialized. I think the CreateSong() and aa.posteritems.push lines need to be moved outside of the for...next block.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2010
12:58 PM
Re: parsing XML question
Also, even after that change, you're depending on the XML file to be correct. You should consider what you want to do if one or more of those values is missing from the XML file. Having the app crash is probably not the best way to handle it.
--Mark
--Mark