On 10/04/03 05:40, Christian Biesinger wrote:
Sudhakar Chandra wrote:
I am trying to find out how exactly I can download a XML file from a remote website and store it into a local file using JS. Can someone give me simple sample JS/XPConnect code to download a file from a remote website and store it locally?
sorry, I have no actual code, but I can describe a way to do that:
1. create a channel for the uri, using nsIIOService
2. create an nsIDownloader object and init it
3. asyncOpen the channel, passing the nsIDownloader as its streamlistener
(this does, of course, not only work for xml files but for any kind of file)


Thanks. I also found http://xul.andreashalter.ch/#10510825071051082204 which has a nice sample snippet. All I had to do was change:

 //save file to target
obj_Persist.saveURI(obj_URI,null,obj_TargetFile);

to:

 //save file to target
obj_Persist.saveURI(obj_URI,null,null,null,null,obj_TargetFile);

Thaths
--
"Life is just one crushing disappointment after another until you just
            wish Flanders was dead." -- Homer J. Simpson
thaths at aunet.org   Slacker At Large   http://www.aunet.org/thaths/
Key fingerprint = 8A 84 2E 67 10 9A 64 03  24 38 B6 AB 1B 6E 8C E4

_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to