22 lines
		
	
	
		
			822 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			22 lines
		
	
	
		
			822 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								## don't forget to provide the location of the actual xml file.
							 | 
						||
| 
								 | 
							
								$xml = "http://dev.k-world.me.uk/sysinfo/xml.php";
							 | 
						||
| 
								 | 
							
								$doc = new DOMDocument();
							 | 
						||
| 
								 | 
							
								$doc->load( $xml);
							 | 
						||
| 
								 | 
							
								## lets read the code block
							 | 
						||
| 
								 | 
							
								$records = $doc->getElementsByTagName( "Distro" );
							 | 
						||
| 
								 | 
							
								foreach( $records as $record )
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								## parse the zip code
							 | 
						||
| 
								 | 
							
								$zip = $record->getElementsByTagName( "Hostname" );
							 | 
						||
| 
								 | 
							
								$zip = $zip->item(0)->nodeValue;
							 | 
						||
| 
								 | 
							
								## parse the city
							 | 
						||
| 
								 | 
							
								$city = $record->getElementsByTagName( "Hardware Name" );
							 | 
						||
| 
								 | 
							
								$city = $city->item(0)->nodeValue;
							 | 
						||
| 
								 | 
							
								## parse the latitude
							 | 
						||
| 
								 | 
							
								$lat = $record->getElementsByTagName( "PCI" );
							 | 
						||
| 
								 | 
							
								$lat = $lat->item(0)->nodeValue;
							 | 
						||
| 
								 | 
							
								## parse longtitude.
							 | 
						||
| 
								 | 
							
								$longtitude = $record->getElementsByTagname( "CPU" );
							 | 
						||
| 
								 | 
							
								$longtitude = $longtitude->item(0)->nodeValue;
							 | 
						||
| 
								 | 
							
								echo "<p>Zip Code: ".$zip."<br/>City: ".$city."<br/>Latitude: ".$lat."<br/>Lontitude:".$longtitude."</p>";
							 | 
						||
| 
								 | 
							
								}
							 |