I am trying to parse data from the XML below (I shortened the data a lot to give an example of what the data looks like).
For each attribute, I would need to store the data in a separate array.
XML File
<report>
<title>Resolution Times (Jun 07 00:21)</title>
<sets>
<set>
<legend>Solved in Less than 2 Hours</legend>
<values>
<value data="8702" date="2012-05-24"/>
<value data="8741" date="2012-05-25"/>
<value data="8741" date="2012-05-26"/>
<value data="8741" date="2012-05-27"/>
</values>
</set>
<set>
<legend>Solved in Less than 24 Hours</legend>
<values>
<value data="36990" date="2012-05-24"/>
<value data="37094" date="2012-05-25"/>
<value data="37096" date="2012-05-26"/>
<value data="37144" date="2012-05-27"/>
</values>
</set>
</sets>
</report>
Below is some test code I am doing to try and read in the data. For testing purposes I am just printing out to see what data is actually pulled.
$verifyReport = new SimpleXMLElement('305262.xml', null, true);
$testing = $verifyReport->sets->set->values->value;
echo '<ol>';
foreach($testing as $data)
{
echo '<li>',
$data['data'].PHP_EOL;
echo '</li>';
}
echo '</ol>';
$testing1 = $verifyReport->sets->sets->values->value;
echo '<ol>';
foreach($testing1 as $data2)
{
echo '<li>',
$data2['data'].PHP_EOL;
echo '</li>';
}
echo '</ol>';
Below is out the output of the data
1. 8702
2. 8741
3. 8741
4. 8741
Warning: Invalid argument supplied for foreach() in
/Applications/XAMPP/xamppfiles/htdocs/tango/test.php on line 23
I am able to pull in the first set (Solved in Less than 2 hours) ok, but when I try to pull the data from the second set (Solved in Less than 24 Hours), I get the above error.
Can anyone help correct this issue?