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.
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.