XML Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
VarwigDude
Forum Newbie
Posts: 12
Joined: Tue Mar 31, 2009 8:08 pm

XML Help

Post by VarwigDude »

Hello Everyone,

I am trying to Use SimpleXML to Work, a Very simple Echo of a Root. I cannot for the life of me figure this out. Any Help would be appreciated. Nothing will print.

Code: Select all

<?php
    $file = "http://weather.aero/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&stationString=KDEN&hoursBeforeNow=1"; 

	// load file 
	$xml = simplexml_load_file($file) or die ("Unable to load XML file!"); 
	
	// access XML data 
    echo 'Metar: '.$xml->metar->raw_text.'<br />';
?>
Peec
Forum Commoner
Posts: 33
Joined: Fri Feb 22, 2008 3:58 am

Re: XML Help

Post by Peec »

should be:
$xml->data[0]->METAR->temp_c


do print_r($xml);
Post Reply