Click to See Complete Forum and Search --> : XML Datafeed Help - Almost there...just need a hand!?


thejazza
06-05-2009, 01:26 AM
Hi I have an xml datafeed from http://xmlfeed.laterooms.com/index.aspx?aid=4066&rtype=1&rid=1

I have made a local xml copy http://www.cytravel.co.uk/test/html/england.xml

And currently the page displays ok here http://www.cytravel.co.uk/test/html/cheap_hotels_in_england.html

What I actually want to do is make all the "region_descriptions" linkable using the url next to them so "Central and South England" should jst be clickable through to http://www.laterooms.com/en/p4066/r242_hotels-in-central-and-south-england.aspx and the same for each region (preferably with an alt tag that states "click here for cheap hotels in (region_description)

The code I am currently using is below will it be possible to fix it fairly easily?
TIA

<script type="text/javascript">
var xmlDoc;
if (window.XMLHttpRequest)
{
xmlDoc=new window.XMLHttpRequest();
xmlDoc.open("GET","england.xml",false);
xmlDoc.send("");
xmlDoc=xmlDoc.responseXML;
}
// IE 5 and IE 6
else if (ActiveXObject("Microsoft.XMLDOM"))
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("england.xml");
}

document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("region");
for (i=0;i<x.length;i++)
{
document.write("<tr><td>");
document.write(x[i].getElementsByTagName("region_description")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(x[i].getElementsByTagName("region_url")[0].childNodes[0].nodeValue);
document.write("</td></tr>");
}
document.write("</table>");
</script>

sommardahl
06-05-2009, 09:21 PM
You could easily do this with a stylesheet (XSL) and skip all the scripting. If you want to explore that, let me know.