Hey people, i’m sorta new to this i’m trying to make a link for some text in an XML from Javascript heres the code i have, what do i need to add to make the link for the ‘title’ field in the XML from the ‘link’ field
i’ve got the XML to display i just need the ‘title’ field to be linked
[CODE]// JavaScript Document
var xmlDoc=null;
if (window.ActiveXObject)
{// code for IE
xmlDoc=new ActiveXObject(“Microsoft.XMLDOM”);
}
else if (document.implementation.createDocument)
{// code for Mozilla, Firefox, Opera, etc.
xmlDoc=document.implementation.createDocument(“”,””,null);
}
else
{
alert(‘Your browser cannot handle this script’);
}
if (xmlDoc!=null)
{
xmlDoc.async=false;
xmlDoc.load(“defencenews/defencenews.xml”);
document.write(“<table border=’1′>”);
var x=xmlDoc.getElementsByTagName(“story”);
for (i=0;i<x.length;i++)
{
document.write(“<tr>”);
document.write(“<td>”);
document.write(
x[i].getElementsByTagName(“title”)[0].childNodes[0].nodeValue);
document.write(“</td>”);
document.write(“<td>”);
document.write(
x[i].getElementsByTagName(“caption”)[0].childNodes[0].nodeValue);
document.write(“</td>”);
document.write(“</tr>”);
}
document.write(“</table>”);
}
and the XML
[CODE]
<?xml version=”1.0″ encoding=”iso-8859-1″ ?>
– <defencenews>
– <story>
<link>/2008/0331_0406.htm#SydneyCOI”</link>
<title>Title of story</title>
<caption>The caption of the story</caption>
</story>
</defencenews>