there isn't much to understand 🙂
with fopen you can open remote file for reading, just pass its URL as parameter. No matter, is it xml or not.
Or you may use not fopen(), but file().
Then read it into a variable. Then open a local file for writing
$local = fopen('local.xml', 'w');
and write that variable into the file.
fwrite($local, $tmpvar);
fclose($local);
Something of the kind.