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 › Importing XML from web APIs
Page Index Toggle Pages: 1
Importing XML from web APIs (Read 292 times)
Importing XML from web APIs
Jan 20th, 2009, 6:50am
 
I am trying to import the xml from a web address such as Spore's API:

http://www.spore.com/rest/assets/search/TOP_RATED/0/5

This is very easy to do using:

XMLElement xml = new XMLElement(this , "http://www.spore.com/rest/assets/search/TOP_RATED/0/5");

However when I try to export this project and open up the webpage at index.html where the applet is embedded, we get hung up on this line.  I am expecting it is something about giving this applet permissions to access this address?  perhaps the 'this' is incorrect when I embed the applet in a webpage.  

Any other ideas about how to import this xml, or another way I might be able to extract the data?
Re: Importing XML from web APIs
Reply #1 - Jan 20th, 2009, 10:18am
 
Classical problem: unless it is signed, an applet cannot access a Web server other than its own.
Re: Importing XML from web APIs
Reply #2 - Jan 20th, 2009, 4:57pm
 
You can put a php "proxy" on your webserver. A script that takes the content from spore.com and sends it to your applet from your server. This way the webservice and your applet are on the same domain.

The script on your server would look something like this...

<?php
 echo file_get_contents("http://www.spore.com/rest/assets/search/TOP_RATED/0/5");
?>
Page Index Toggle Pages: 1