I got bored and hacked a javascript solution together from some web tutorials. No need for PHP or anything.
"sample.xml" file that could be stored on a remote server:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<content>
<item>
<link>http://www.yahoo.com/</link>
<text>This links to yahoo.com</text>
<image>http://us.a1.yimg.com/us.yimg.com/i/ww/beta/y3.gif</image>
</item>
<item>
<link>http://www.google.com</link>
<text>Google is good.</text>
<image>http://www.google.com/intl/en/images/logo.gif</image>
</item>
</content>
And the following is an html page that will parse that XML file into HTML and place it where you want in an html page:
[html]
<html>
<head>
<title>XML Parser</title>
<script language="JavaScript">
var xmlhttp;
var output = "";
function loadXMLDoc(url)
{
// code for Mozilla, etc.
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest()
xmlhttp.onreadystatechange=xmlhttpChange
xmlhttp.open("GET",url,true)
xmlhttp.send(null)
}
// code for IE
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
if (xmlhttp)
{
xmlhttp.onreadystatechange=xmlhttpChange
xmlhttp.open("GET",url,true)
xmlhttp.send()
}
}
}
function xmlhttpChange()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyStatehahahaha4)
{
// if "OK"
if (xmlhttp.statushahahaha200)
{
xmlObj = xmlhttp.responseXML;
parseXML(xmlObj);
}
else
{
alert("Problem retrieving XML data")
}
}
}
function parseXML(xmlObj)
{
items = xmlObj.getElementsByTagName("item");
for(i=0;i<items.length;i++)
{
link = items[i].getElementsByTagName("link")[0].firstChild.nodeValue;
text = items[i].getElementsByTagName("text")[0].firstChild.nodeValue;
image = items[i].getElementsByTagName("image")[0].firstChild.nodeValue;
output += "<p><a href=\"" + link + "\">"
+ "<img src=\""+image+"\" align=left>"
+ text
+ "</a></p><hr/>";
}
document.getElementById("targetText").innerHTML = output;
}
</script>
</head>
<body onLoad="loadXMLDoc('sample.xml')">
<p>Output from xml document:</p>
<div id="targetText">
<!-- output goes here -->
</div>
</body>
[/html]