Read XML file and write to a php array/file


I need to update the country list of my website and I want to automate the process. Country list can be found here

I tried it this way – (PHP XML Expat Parser)
However, this didn’t seem to work well as I was confused where to actually ‘get’ the data and print it to my own array for later use.

Now I want to try it using XML DOM
( ).

Just want to check with everyone, if I had a simple XML file to read, that contained a country code and country name as follows:

< Entry> 
< Country_name>AFGHANISTAN</ Country_name>
< Code_element>AF</ Code_element>

I want to read this file (DOM method), and then feed the data into a separate file/array of mine that will be accessed by my website. What PHP xml functions would YOU use/recommend to do this simple task?

Any help in this regards is appreciated.

Hi isurupalliyaguru,
Check your link what you have given above it seems to be( “404 error”.