This might be a very simple answer but it's been stumping me.

I need to load an xml file so Ican parse in in javascript. But the file is located on a different server entirely. Can I download it to disc with javascript, so I can load it later?

Thanks for any help.

you can use your brouwser to download the xml maualy
for automatic download you need to write a server site script (php-curl)


You can try with Ajax. If it cannot get the xml directly, you can use an ajax function to access a php file on your server, that gets and returns the xml (using cUrl, or file_get_contents() ).

How would I use the PHP method?


    $feed_url = “”;
    $data = file_get_contents($feed_url);

get more info about that method here.


    function getData($feed_url) {

        $curl_handle = curl_init();

        curl_setopt ($curl_handle, CURLOPT_URL,$feed_url);
        curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($curl_handle);

        return $result;


Get more info about cURL here and here.

Further reading on which is best :

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.