Read from XML file and write to a php file

Hi,

I need to update the country list of my website and I want to automate the process. Country list can be found here
http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm

In that XML file they have given the data is in following format
<ISO_3166-1_Entry> <ISO_3166-1_Country_name>AFGHANISTAN</ISO_3166-1_Country_name>
<ISO_3166-1_Alpha2_Code_element>AF</ISO_3166-1_Alpha2_Code_elemen>
</ISO_3166-1_Entry>
<ISO_3166-1_Entry>

I need to read the XML file and get the data then write this in a PHP file in following format. (I prefer the DOM method)
<?php
$countries[“AF”] = “Afghanistan”;
$countries[“AL”] = “Albania”;
$countries[“DZ”] = “Algeria”;

Any help in this regards is much appreciated.