This function retrieves any sort of file from the web:
Code:
function saveRemoteFile(From, To)
{
var oXmlHttp = new ActiveXObject("Msxml2.XmlHttp.4.0"); //Change to version 3 if necessary
oXmlHttp.open("GET", From, false);
oXmlHttp.send();
if (oXmlHttp.status == 200)
{
var oStream = new ActiveXObject("Adodb.Stream");
oStream.type = 1; //Binary
oStream.open();
oStream.write(oXmlHttp.responseBody);
oStream.saveToFile(To, 1 && 2);
oStream.close();
}
else
{
throw new Error(oXmlHttp.statusText); //Needs improving
}
}
saveRemoteFile("http://www.google.com", "C:\\myFolder\\myGooglePage.htm");
If you know the data is going to be XML then once you have opened and sent you can just do:
Code:
//create msxml2.xmlhttp.4.0, open and send
oXmlHttp.responseXML.save(<path to save to>);
--
Joe (
Microsoft MVP - XML)