We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Retrieving a huge xml file for parsing.
Page Index Toggle Pages: 1
Retrieving a huge xml file for parsing. (Read 480 times)
Retrieving a huge xml file for parsing.
Feb 22nd, 2009, 9:26pm
 
Hi

Someone did something.. -> now I have been given a URL that looks like this:
http://10.10.10.10:8080?ServiceName=common&ActionName=readstatistics
when called through a browser(Safari on a mac), the browser response is to start downloading the file returned. The return data is 14 MB of xml data, so good thing it does not try to open and parse it in my browser.

When it is finished I have a file called "DownloadedFile" of type "plain text", no visible extension(clicking it open the file in TextEdit and displays the xml data as expected). This file I rename with an extension of .xml and put it into my processing sketch like this:   XMLElement bulk = new XMLElement(this, url); where "url" is the filename I saved the data under and not the url above.

My question is what could I do to make processing get the xml data directly?
putting the url string for the server directly into the XMLElement constructor yields an error, which does not surprise me at all.

Do I need to stream to a file or something down that alley?

I sort of just need a push in the right directions as I have no luck searching the site, because I don't really have any keywords to describe the situation with.

Hope someone can help, Thanks
Re: Retrieving a huge xml file for parsing.
Reply #1 - Feb 23rd, 2009, 4:04am
 
You should be able to pass the URL to the XMLElement constructor, but I think you're missing a slash before the question mark. Try this:

XMLElement xml = new XMLElement(this, "http://10.10.10.10:8080/?ServiceName=common&ActionName=readstatistics");

But in general, if you need to download 14 MB of data, you'll probably want to cache it separately anyway. The saveStream() method does that, which will read a URL and write directly to a file so that it can be retrieved later.
Re: Retrieving a huge xml file for parsing.
Reply #2 - Feb 23rd, 2009, 2:58pm
 
Thank you Fry

It was the / that was missing. I guess Safari is just nice and understood the url anyways.

I experimented with the saveStream(), I guess that will work as well when I parse it the right url.

Is there any Events or fields accosiated with the XMLElement over saveStream that would make me able to show some sort of progress/finished feedback to a user. Something like url.totalBytes() / url.loadedBytes().

I seems the Dan Shiffman XML Library which has these is not compatible with processing anymore?

Thanks again.
Re: Retrieving a huge xml file for parsing.
Reply #3 - Dec 2nd, 2009, 7:12pm
 
You might also want to look at vtd-xml, the next generation XML processing model that is far more powerful than DOM and SAX

Page Index Toggle Pages: 1