Tuesday, May 14, 2013

Pull data from XML file using PHP

In order to pull data from an XML file, the easiest way is to use the built-in function simplexml_load_file. PHP 5 must be installed on your web server, though. The code below should give you the general idea on how to get started.

<?php

$file = simplexml_load_file("myfile.xml");

foreach ($file->topNode as $value) {

echo $value->secondaryNode;

}

?>

This code will go into your xml file loop through each node and print out all of the secondary nodes within your document.

Try my gator hunting game available on iPhone in the iTunes App Store

1 comment: