Save remote XML to local website folder

Posted on 16th Feb 2014 by admin

Hi, I hope you can help me out. I would like to be able to pull an XML file from another site and then store it in a local folder on my site. That way, I would only need to pull the xml file once in a while instead of every time someone opens that page.

here is a snippet of code I found, but the size of the saved XML file is smaller and is not consistently the same size of file. Some of the information gets lost.

$fp = fopen( 'http://forecast.weather.gov/MapClick.php?lat=45.21640&lon=-112.63700&FcstType=dwml', 'r' );
$string = fread( $fp, 1024*9 );
fclose( $fp );

$fp = fopen( 'weather.xml', 'w' );
fwrite( $fp, $string );
fclose( $fp );

I hope I explained that

Other forums