I am parsing an xml file successfully in PHP, but having difficulty parsing a specific entry trying to output a table.
My xml is as follow
<OutputData Name="ExchangeRate" ContentTypeID="">
<DataTitle>Exchange</DataTitle>
<DataInfo>
<TABLE CLASS="DataTable">
<TR><TD>1.00 GBP = 1.68 ALL</TD></TR>
<TR><TD>1.00 USD = 1.58 ALL</TD></TR>
<TR><TD>1.00 EUR = 1.35 ALL</TD></TR>
<TR><TD>Currency conversion rates as of January 2012</TD></TR>
</TABLE>
</DataInfo>
</OutputData>
if I try to output it this way
$info = $outputinfo->DataInfo;
I am getting an error.
any help?
My code is as follow
$xmlfile = $currenttitle.".xml";
$info = simplexml_load_file($xmlfile);
$region = $country->Region[0];
$section = $region->Section;
if($info){
foreach ($region->Section as $sectioninfo){
$title = $sectioninfo->SectionTitle;
echo "<b>$title</b><br />\n";
$output = $sectioninfo->OutputData;
foreach ($sectioninfo->OutputData as $outputinfo){
$titleinfo = $outputinfo->DataTitle;
$info = $outputinfo->DataInfo;
}
}
for the section above, I get the Title display, as Exchange, but the Table is not rendered.
SOLUTION
Thanks to h4b0 who put me in the right direction
$rowinfo = $outputinfo->DataInfo->TABLE->TR->TD;
foreach ($outputinfo->DataInfo->TABLE->TR as $rowexchange){
echo $rowexchange->TD."<br />";
}
I guess you won’t get error if you try
$info = $outputinfo->DataInfo->TABLE->TR->TD. If I’m wrong, post your error message.