Jump to content

[SOLVED] convertine simple XML doc to html table with php


prakash

Recommended Posts

how can I convert simple xml data like below to html table using php

<?xml version="1.0" encoding="UTF-8"?>
<result>
<pagerank>8</pagerank>
<alexaRank>5</alexaRank>
<dmoz>1</dmoz>
<backlinksGoogle>825,000</backlinksGoogle>
<backlinksYahoo>2,300,000</backlinksYahoo>
<backlinksMSN>0</backlinksMSN>
<resultsAltaVista>47,100,000</resultsAltaVista>
<resultsAllTheWeb>39,500,000</resultsAllTheWeb>
<thumbnail>http://images.websnapr.com/?url=msn.com&size=t</thumbnail>
</result>

if (phpversion() >= 5) {
echo '<table>', PHP_EOL;
foreach (simplexml_load_string($xml) as $key => $value) {
	echo '<tr><td>', $key, '</td><td>', $value, '</td></tr>', PHP_EOL;
}
echo '</table>', PHP_EOL;
}

 

actually the xml is built from a php script on another file like somexmlfile.php by passing a varaible

 

let's say somexmlfile.php?url=msn.com

 

so how can I set the value of $xml to the somexmlfile.php?url=msn.com output

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.