Forum Discussion

destruk's avatar
destruk
Streaming Star
15 years ago

Parse XML in chunks?

To eliminate the memory limit of the Roku boxes, is it possible to parse an RSS feed in pieces, rather than having to parse the entire thing? And how could you resume parsing when needed later in the script?
Or is truly the best solution to use mysql and do a limit query?

4 Replies

  • I imagine if you need, you could use a regular expression to break the downloaded RSS into chunks without too much trouble. If you post a sample, I'd be happy to help.
  • destruk's avatar
    destruk
    Streaming Star
    I'm still trying to get a feel for how this works. I ran across this post which makes me worry about the memory limit - viewtopic.php?f=34&t=35105&p=226658&hilit=out+of+memory+xml#p226658
    There aren't any specifications as to how much ram each roku device ships with, how fast the processor is, etc etc, so for now I have the following questions:
    When downloading an XML, what is the size of the storage area for the source file? ie - if I download a 3MB XML to parse, or pick and choose what data to add to an array, what would be the file size limit to hold the source xml?
    Does all the XML need to exist before the screen is displayed, or can I have it load the episode xml based on which category is selected?
    Most of the examples use static data - is there a better dynamic example available anywhere besides deviantart and/or the video player?
    Does the size of a url matter in a content list as far as memory goes? - ie is there any ram benefit to using a url shortening service like tinyurl to allow you to have more array entries?
  • jbrave's avatar
    jbrave
    Channel Surfer
    Generally, one would get the XML from a server that has URL based controls on the amount of data returned. For instance, I request data for my channels in chunks of 20 records so there is never a problem.

    Http://API.company.com/files.XML?limit=20&page=0

    Which should give a list of 20 files. To get the next 20, page=1

    So if you are generating XML, make sure you have a control like that set up. If you are just serving XML as a file, then break it up into many files like 1.XML, 2.XML, 3.XML etc.

    -Joel