Simple Quesiton on URLs

I am trying to learn Roku channel development. I took the “videoplayer” example and was going to experiment with the category feeds. I discovered that the category files were present in the application’s tree as well as online, and I changed the line:

    conn.UrlPrefix   = "http://rokudev.roku.com/rokudev/examples/videoplayer/xml"

to

    conn.UrlPrefix   = "file://pkg:/xml"

to pull the local copy of the file instead of hitting the web server at rokudev.roku.com. The only other change i made was to add a debugging line after the “Can’t parse feed” so I could see the results of the fetch of the URL:

    if not xml.Parse(rsp) then
         print "Can't parse feed"
         print "'" + rsp + "'"
        return invalid
    endif

It looks like the HTTP fetch returns nothing:

created feed connection for file://pkg:/xml/categories.xml
url: file:///tmp/plugin/FDAAAA1tnmYw/pkg:/xml/categories.xml
Took: 5ms
Can't parse feed
''

Any clues on what I’m doing wrong?

Two things. First, the path should look more like this:

conn.UrlPrefix   = "pkg:/xml"

Also, you can’t read a local file using roURLTransfer. You’ll need to use ReadASCIIFile() as documented on p34 of the BrightScript Reference Manual.

Thanks for the quick response. Added the following line after

    xml=CreateObject("roXMLElement")
    rsp = ReadAsciiFile("pkg:/xml/categories.xml")
    if not xml.Parse(rsp)
        '...

No joy in mudville. The app doesn’t seem to run at all - connecting to the debug port 8085 yields nothing.

“MikeL1” wrote:

No joy in mudville. The app doesn’t seem to run at all - connecting to the debug port 8085 yields nothing.

At a minimum is should state it’s running the code, and it should give you an error message and the debugging console if there’s an error. Sometimes it seems the debugging port can get stuck for me (if, for example, I let the computer go to sleep and time out the telnet connection), and I need to reset the Roku.

Thanks, will try rebooting.

Post-reboot I actually get it to install and get debugging output but it’s not reading the file:

    xml=CreateObject("roXMLElement")
    rsp = ReadAsciiFile("pkg:/xml/categories.xml")
    if not xml.Parse(rsp)
         print "Can't parse feed"
         print "Rsp = '" + rsp + "'"
        return invalid
    endif

gives me the following:

Can't parse feed
Rsp = ''

If you’re using included makefile to package and install the sample channel, the xml directory will be excluded from the package, which could cause the problem you’re seeing.

Doh! Should have done more checking, but I’m new to this. That did the trick. Hopefully I wont’ be pestering you all anymore (at least not for a while).

Thank you!

“RokuChris” wrote:
Also, you can’t read a local file using roURLTransfer. You’ll need to use ReadASCIIFile() as documented on p34 of the BrightScript Reference Manual.

FYI you can read a local file using roURLTransfer just as with a web browser, the URL syntax is “file://pkg:/xml/categories.xml”.