Help needed parsing XML
Posted: Mon Sep 28, 2009 6:52 am
Hi, I'm hoping someone may be able to help...
I'm trying to display a single value from an XML file but am getting a blank output (but no errors).
The code I'm using is this:
And this is the XML:
Any help would be really appreciated!
I'm trying to display a single value from an XML file but am getting a blank output (but no errors).
The code I'm using is this:
Code: Select all
if(!$xml=simplexml_load_file('sample.xml')){
trigger_error('Error reading XML file',E_USER_ERROR);
}
$result = $xml->test; //This is just a test which works
$result1 = $xml->number[2];
echo $result; // This displays TEST
echo $result1; //I was hoping this would display 3000Code: Select all
<test>TEST</test>
<chart_data>
<row>
<string></string>
<number tooltip="£3000">3000</number>
<number tooltip="£3000.56">3000.56</number>
<number tooltip="£3000">3000</number>
</row>
</chart_data>