AzaraT
01-06-2008, 10:44 AM
Hi there!
I currently have a script that loads an XML file with ajax, how ever theres quite alot of data, and well, it looks quite messy. So I want to load it up in a table instead of what im doing now (see the scrips), so it looks more like this: http://tothegame.com/monthlyreleases.asp
Xml:
<?xml version="1.0" encoding="UTF-8" ?>
<Games>
<isvalid></isvalid>
<fromdate>2008-01-01</fromdate>
<todate>2008-01-31</todate>
<gamecount>54</gamecount>
<Game>
<GameID>6499</GameID>
<Title><![CDATA[PDC World Championship Darts 2008]]></Title>
<Category>Sport</Category>
<URLGameinfo><![CDATA[http://www.tothegame.com/game.asp?id=6499]]></URLGameinfo>
<Platform>
<ID>9</ID>
<Title>Wii</Title>
</Platform>
<ReleaseDates>
<Scandinavia>2008-01-11</Scandinavia>
<UK>2008-01-11</UK>
<US>N/A</US>
</ReleaseDates>
<UKPublisher><![CDATA[Oxygen Interactive]]></UKPublisher>
<Developer><![CDATA[To Be Announced]]></Developer>
</Game>
<Game>
<GameID>6500</GameID>
<Title><![CDATA[PDC World Championship Darts 2008]]></Title>
<Category>Sport</Category>
<URLGameinfo><![CDATA[http://www.tothegame.com/game.asp?id=6500]]></URLGameinfo>
<Platform>
<ID>1</ID>
<Title>PC</Title>
</Platform>
<ReleaseDates>
<Scandinavia>2008-01-11</Scandinavia>
<UK>2008-01-11</UK>
<US>N/A</US>
</ReleaseDates>
<UKPublisher><![CDATA[Oxygen Interactive]]></UKPublisher>
<Developer><![CDATA[To Be Announced]]></Developer>
</Game>
and that continues...........
and the html
<html>
<head>
<script>
var xmlHttp;
function loadXML()
{
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=test;
xmlHttp.open("GET","release_list_jan.xml",true);
xmlHttp.send(null);
}
function test()
{
if(xmlHttp.readyState==4)
{
var xmlDoc=xmlHttp.responseXML.documentElement;
for(var i=0;i<xmlDoc.getElementsByTagName("Game").length;i++)
{
Title = document.createElement("span");
var a = document.createElement("b");
var h = document.createElement("span");
a.appendChild(document.createTextNode("Game Title: "));
h.appendChild(document.createTextNode(xmlDoc.getElementsByTagName("Game")[i].getElementsByTagName("Title")[0].childNodes[0].nodeValue+" "))
Title.appendChild(a);
Title.appendChild(h);
Category = document.createElement("span");
a = document.createElement("b");
h = document.createElement("span");
a.appendChild(document.createTextNode("Genre: "));
h.appendChild(document.createTextNode(xmlDoc.getElementsByTagName("Game")[i].getElementsByTagName("Category")[0].childNodes[0].nodeValue+" "))
Category.appendChild(a);
Category.appendChild(h);
Platform = document.createElement("spaan");
a = document.createElement("b");
h = document.createElement("span");
a.appendChild(document.createTextNode("Platform: "));
h.appendChild(document.createTextNode(xmlDoc.getElementsByTagName("Game")[i].getElementsByTagName("Platform")[0].getElementsByTagName("Title")[0].childNodes[0].nodeValue))
Platform.appendChild(a);
Platform.appendChild(h);
if(document.getElementById("spil").hasChildNodes()) document.getElementById("spil").appendChild(document.createElement("br"));
document.getElementById("spil").appendChild(Title);
document.getElementById("spil").appendChild(Category);
document.getElementById("spil").appendChild(Platform);
}
}
}
</script>
</head>
<body onLoad="loadXML()">
<div id="spil"></div>
</body>
</html>
I hope someone can help me make this less messy :)
Thanks
AzaraT
I currently have a script that loads an XML file with ajax, how ever theres quite alot of data, and well, it looks quite messy. So I want to load it up in a table instead of what im doing now (see the scrips), so it looks more like this: http://tothegame.com/monthlyreleases.asp
Xml:
<?xml version="1.0" encoding="UTF-8" ?>
<Games>
<isvalid></isvalid>
<fromdate>2008-01-01</fromdate>
<todate>2008-01-31</todate>
<gamecount>54</gamecount>
<Game>
<GameID>6499</GameID>
<Title><![CDATA[PDC World Championship Darts 2008]]></Title>
<Category>Sport</Category>
<URLGameinfo><![CDATA[http://www.tothegame.com/game.asp?id=6499]]></URLGameinfo>
<Platform>
<ID>9</ID>
<Title>Wii</Title>
</Platform>
<ReleaseDates>
<Scandinavia>2008-01-11</Scandinavia>
<UK>2008-01-11</UK>
<US>N/A</US>
</ReleaseDates>
<UKPublisher><![CDATA[Oxygen Interactive]]></UKPublisher>
<Developer><![CDATA[To Be Announced]]></Developer>
</Game>
<Game>
<GameID>6500</GameID>
<Title><![CDATA[PDC World Championship Darts 2008]]></Title>
<Category>Sport</Category>
<URLGameinfo><![CDATA[http://www.tothegame.com/game.asp?id=6500]]></URLGameinfo>
<Platform>
<ID>1</ID>
<Title>PC</Title>
</Platform>
<ReleaseDates>
<Scandinavia>2008-01-11</Scandinavia>
<UK>2008-01-11</UK>
<US>N/A</US>
</ReleaseDates>
<UKPublisher><![CDATA[Oxygen Interactive]]></UKPublisher>
<Developer><![CDATA[To Be Announced]]></Developer>
</Game>
and that continues...........
and the html
<html>
<head>
<script>
var xmlHttp;
function loadXML()
{
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=test;
xmlHttp.open("GET","release_list_jan.xml",true);
xmlHttp.send(null);
}
function test()
{
if(xmlHttp.readyState==4)
{
var xmlDoc=xmlHttp.responseXML.documentElement;
for(var i=0;i<xmlDoc.getElementsByTagName("Game").length;i++)
{
Title = document.createElement("span");
var a = document.createElement("b");
var h = document.createElement("span");
a.appendChild(document.createTextNode("Game Title: "));
h.appendChild(document.createTextNode(xmlDoc.getElementsByTagName("Game")[i].getElementsByTagName("Title")[0].childNodes[0].nodeValue+" "))
Title.appendChild(a);
Title.appendChild(h);
Category = document.createElement("span");
a = document.createElement("b");
h = document.createElement("span");
a.appendChild(document.createTextNode("Genre: "));
h.appendChild(document.createTextNode(xmlDoc.getElementsByTagName("Game")[i].getElementsByTagName("Category")[0].childNodes[0].nodeValue+" "))
Category.appendChild(a);
Category.appendChild(h);
Platform = document.createElement("spaan");
a = document.createElement("b");
h = document.createElement("span");
a.appendChild(document.createTextNode("Platform: "));
h.appendChild(document.createTextNode(xmlDoc.getElementsByTagName("Game")[i].getElementsByTagName("Platform")[0].getElementsByTagName("Title")[0].childNodes[0].nodeValue))
Platform.appendChild(a);
Platform.appendChild(h);
if(document.getElementById("spil").hasChildNodes()) document.getElementById("spil").appendChild(document.createElement("br"));
document.getElementById("spil").appendChild(Title);
document.getElementById("spil").appendChild(Category);
document.getElementById("spil").appendChild(Platform);
}
}
}
</script>
</head>
<body onLoad="loadXML()">
<div id="spil"></div>
</body>
</html>
I hope someone can help me make this less messy :)
Thanks
AzaraT