<?php
//$file contains place of the KML file we will be getting our node information from
$file = "inc/example.kml";

//Check if the file exists, if it does we load it. If it doesn't we exit and return an error message
if (file_exists($file)) 
{
    $xml = simplexml_load_file($file);
} 
else 
{
    exit('Failed to open example.xml.');
}

//Counter starts at 0. For every foreach done counter will go up by one. Thus resulting in total nodes added(counter starts at 0 so add 1 to the total )
$counter = 0;

//Now we go through the xml files, storing the data in an array called $markers. More data can be stored by adding more rows in the array 
foreach($xml->Document->Folder->Placemark as $placemark)
{
	
	$markers[] = array(	"latitude"=>$placemark->LookAt->latitude,
						"longitude"=>$placemark->LookAt->longitude,
						"name"=>$placemark->name,
						"description"=>$placemark->description,
						"id"=>$counter);
	$counter++;			
}