I am having a xml file which is having set of records ,And I want to load these records into php I am trying to pass these values to php but my code is not working .can any one tell me how to parse these xml data into php
Here is my xml data:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <report>
<report-name name="Criteria performance report #54afd4b9c3fd9" />
<date-range date="Dec 1, 2014-Dec 31, 2014" />
- <table>
- <columns>
<column name="day" display="Day" />
<column name="adGroupID" display="Ad group ID" />
<column name="adGroup" display="Ad group" />
<column name="ad" display="Ad" />
<column name="descriptionLine1" display="Description line 1" />
<column name="descriptionLine2" display="Description line 2" />
<column name="displayURL" display="Display URL" />
<column name="clicks" display="Clicks" />
<column name="convertedClicks" display="Converted clicks" />
<column name="cost" display="Cost" />
<column name="ctr" display="CTR" />
</columns>
<row day="2014-12-01" adGroupID="16385367652" adGroup="Urology" ad="Best Urology Treatment" descriptionLine1="Get treated in top urology hospital" descriptionLine2="Take a free advice from our experts" displayURL="www.ainuindia.com" clicks="0" convertedClicks="0" cost="0" ctr="0.00%" />
<row day="2014-12-01" adGroupID="16282238572" adGroup="Kidney Stones Removal" ad="Kidney Stone Removal" descriptionLine1="Get treated at top kidney center" descriptionLine2="Take a free advice from our experts" displayURL="www.ainuindia.com" clicks="0" convertedClicks="0" cost="0" ctr="0.00%" />
<row day="2014-12-01" adGroupID="16282238572" adGroup="Kidney Stones Removal" ad="Kidney Stone Removal" descriptionLine1="Get treated at top kidney center" descriptionLine2="Take a free advice from our experts" displayURL="www.ainuindia.com" clicks="0" convertedClicks="0" cost="0" ctr="0.00%" />
</table>
</report>
And my php code is :
if( ! $xml = simplexml_load_file(dirname(__FILE__) . '/report.xml') )
{
echo 'unable to load XML file';
}
else
{
foreach( $xml as $table )
{
echo 'Adgroup id: '.$table->columns->adGroupID.'<br />';
echo 'group: '.$table->columns->adGroup.'<br />';
echo 'Ad: '.$table->columns->ad.'<br />';
echo 'Description1: '. $table->columns->descriptionLine1.'<br />';
echo 'Description2: '.$table->columns->descriptionLine2.'<br />';
}
}