Reputation: 139
I am trying to fetch an XML file hosted on a web-server for within an After Effects script.
Can anyone clarify why this approach doesn't seem to work?
//var xml_path = "/c/test.xml";
var xml_path = "http://transfer.proshopeurope.com/TEMP/test.xml";
function getXML(){
var xml_file = new File(this.xml_path);
if(xml_file.open("r")){
var xml_string = xml_file.read();
var xml = new XML(xml_string);
xml_file.close();
return xml;
}else{
return false;
}
}
$.writeln(getXML());
It works fine, by the way, if I use the local path commented out at the top.
Upvotes: 1
Views: 2123
Reputation: 2967
You don't necessarily need to use sockets. The main reason being that Sockets do not support SSL. So if your connection is over SSL, ExtendScripts sockets will fail.
You can use system.callSystem() to make shell calls. For example, look at the code under "EDIT 2" in this SO question I asked a while back.
For a more in depth discussion, check out this thread on Adobe's Forums where I discussed a bit more details.
Upvotes: 0
Reputation: 1440
You can't use 'new File' for url, you need to use 'Sockets':
reply = "";
conn = new Socket;
if (conn.open ("transfer.proshopeurope.com:80")) {
// send a HTTP GET request
conn.writeln("GET /TEMP/test.xml HTTP/1.0\r\nHost: transfer.proshopeurope.com\r\n");
// and read the server's reply
reply = conn.read(999999);
conn.close();
}
This will return all the response into 'reply' then you should use regex to get only the xml.
Upvotes: 2