Output xml result into table using PHP -
i have put php script read content of xml file , output result html page. bit struggling how format output table.
php script:
<?php // loading xml file $xml = simplexml_load_file("ftpxml.xml"); echo "<h2>".$xml->getname()."</h2><br />"; foreach($xml->children() $ftpxml) { echo "pid : ".$ftpxml->attributes()->pid."<br />"; echo "account : ".$ftpxml->attributes()->account." <br />"; echo "time : ".$ftpxml->attributes()->time." <br />"; echo "<hr/>"; } ?>
html result:
pid : 279 account : account001 time : 137 ---------------------------------------------------------------- pid : 268 account : account002 time : 301 ---------------------------------------------------------------- pid : 251 account : account003 time : 5 ----------------------------------------------------------------
i lost how display each table headings , corresponding contents. new php please guide me or if answered else where, please provide link can learn it.
thanks
i assume want make different values different fields in table:
// loading xml file $xml = simplexml_load_file("ftpxml.xml"); echo "<h2>".$xml->getname()."</h2><br />"; echo "<table><thead><tr><th>pid</th><th>account</th><th>time</th></tr></thead><tbody>"; foreach($xml->children() $ftpxml) { echo '<tr>'; echo '<td>' . $ftpxml->attributes()->pid . "</td>"; echo '<td>' . $ftpxml->attributes()->account . "</td>"; echo '<td>' . $ftpxml->attributes()->time . "</td>"; echo '</tr>'; } echo '</tbody></table>';
Comments
Post a Comment