Home > PHP, Tips, Tutorial > Read XML File

Read XML File


Suatu ketika saya diharuskan membaca data dari XML File yang digenerate hanya ketika saya melakukan request ke server dimana file XML itu dibuat. Untuk lebih jelasnya saya akan jelaskan dalam tutorial.

/ * Ambil File XML dan Simpan Dalam Suatu File */
$url = “http://192.168.0.102/”;
$str = file_get_contents($url);
$fh = fopen(‘content.xml’, ‘w’) or die(“can’t open file”);
fwrite($fh, $str);
$data = simplexml_load_file(“content.xml”);
$jum= count($data)/3;

/* Display Isi XML */
for ($i=0;$i<$jum;$i++){
echo $data->KodeMember[$i];
}

Semoga Bermanfaat

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: