Hey,
Ok, I am parsing a XML file into a HTML doc using javascript. At the moment my javascriptlooks like this ->
---------------------------------------------------------
<script type="text/javascript">
var xmlDoc
function loadXML()
{
//load the rfid xml file for Internet Explorer
if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("sample.xml");
getmessage()
}
// load the rfid xml file for Mozilla
else if (document.implementation && document.implementation.createDocument)
{
xmlDoc= document.implementation.createDocument("","",null);
xmlDoc.load("xmlDoc.onload=getmessage
}
else
{
alert('Your browser does not support this script');
}
}
function getmessage()
{
// Load the first four articles titles
document.getElementById("title1").innerHTML=xmlDoc.getElementsByTagName("title")[1].firstChild.nodeValue
document.getElementById("link1").innerHTML=xmlDoc.getElementsByTagName("link")[1].firstChild.nodeValue
</script>
--------------------------------------------------
And, within my body tag, I display the contents of the title field like this ->
-------------------------------
<span id="title1"></span>
-----------------------------------
Now this works fine, the data inside the title tag gets displayed on the screen. However, There is another tag under the title tag in the xml document that contains a link for a web address. What I want is the text that is outputted from the title tag to link to the web address thats in the link tag.
I have tried using the id "link1" is a href and many similar ways but it wont work. Im not sure if this is possible via html or whether I need javascript to do it.
Any help is much appreciated.
Thanks for your time.
Now I have tried
Ok, I am parsing a XML file into a HTML doc using javascript. At the moment my javascriptlooks like this ->
---------------------------------------------------------
<script type="text/javascript">
var xmlDoc
function loadXML()
{
//load the rfid xml file for Internet Explorer
if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("sample.xml");
getmessage()
}
// load the rfid xml file for Mozilla
else if (document.implementation && document.implementation.createDocument)
{
xmlDoc= document.implementation.createDocument("","",null);
xmlDoc.load("xmlDoc.onload=getmessage
}
else
{
alert('Your browser does not support this script');
}
}
function getmessage()
{
// Load the first four articles titles
document.getElementById("title1").innerHTML=xmlDoc.getElementsByTagName("title")[1].firstChild.nodeValue
document.getElementById("link1").innerHTML=xmlDoc.getElementsByTagName("link")[1].firstChild.nodeValue
</script>
--------------------------------------------------
And, within my body tag, I display the contents of the title field like this ->
-------------------------------
<span id="title1"></span>
-----------------------------------
Now this works fine, the data inside the title tag gets displayed on the screen. However, There is another tag under the title tag in the xml document that contains a link for a web address. What I want is the text that is outputted from the title tag to link to the web address thats in the link tag.
I have tried using the id "link1" is a href and many similar ways but it wont work. Im not sure if this is possible via html or whether I need javascript to do it.
Any help is much appreciated.
Thanks for your time.
Now I have tried