<%@ Language=VBScript %> <HTML> <HEAD> <SCRIPT LANGUAGE=javascript> <!-- function GetAndSaveAFile(sFileName) { // für XMLHTTP abholen des Streams var XMLHTTP = new ActiveXObject("MSXML2.XMLHTTP"); // open mit false = für syncrones holen der Daten (Async = false) XMLHTTP.open("Get","http://localhost/developer2/XML/XMLStream.asp?FileName=" + sFileName,false); XMLHTTP.send(); var XMLDoc = new ActiveXObject("MSXML2.DOMDocument"); XMLDoc.loadXML(XMLHTTP.responseText);
// Daten-Stream knoten referenziieren var Node = XMLDoc.documentElement.selectSingleNode("/Root/Data");
// mit Hilfe des Stream-Objektes den XML-Daten-Stream als Datei abspeichern var Stream = new ActiveXObject("ADODB.Stream"); Stream.Type=1; // 1 = adTypeBinary Stream.Open(); Stream.Write(Node.nodeTypedValue); Stream.SaveToFile("C:downloadedfile.doc",2); // 2 = adSaveCreateOverWrite } //--> </SCRIPT>
</HEAD> <BODY> <input type="button" name="bGetFile" value="Download a File" onclick="GetAndSaveAFile('File1.doc')"> </BODY> </HTML>
|