PDA

View Full Version : parse xml from url in non IE browsers



beahuman
04-02-2009, 04:06 PM
Hi everyone. I'm new here. I know there are similar posts in the forum pertaining to my topic but I couldn't get any of them to work for me. So my apologies. I'm hoping someone can take a look at the code below and tell me what ridiculously simple thing I'm overlooking to parse my xml from a url. As usual, it works perfect with IE, but not FF and the like.

Any help without chastisement would be greatly appreciated.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Ivanhoe Medical Feed</title>


<style type="text/css">
/* CSS Document */


td {
padding-left:8px;
}

ul {
list-style-type:none;
position:relative;
top:-40px;
left:-35px;
}

a:link {
text-decoration:underline;
color:#000033;
}

a:hover {
text-decoration:none;
color:#FFFFFF;
}

a:visited {
color: #FF0000;
}

#healthtable {
font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
font-weight:bold;
text-decoration: none;
}
</style>

<script type="text/javascript" language="javascript">
function parseXML(){
try{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
catch(e)
{
try //Firefox, Mozilla, Opera, etc.
{
xmlDoc=document.implementation.createDocument("","",null);
}
catch(e)
{
alert(e.message);
return;
}
}
xmlDoc.async=false;
xmlDoc.load("http://ivanhoe.com/syndication/newsflashxml.cfm");

document.getElementById("atitle").innerHTML= xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue;
document.getElementById('atitle').href = xmlDoc.getElementsByTagName("url")[0].childNodes[0].nodeValue;
document.getElementById("btitle").innerHTML= xmlDoc.getElementsByTagName("title")[1].childNodes[0].nodeValue;
document.getElementById('btitle').href = xmlDoc.getElementsByTagName("url")[1].childNodes[0].nodeValue;
document.getElementById("ctitle").innerHTML= xmlDoc.getElementsByTagName("title")[2].childNodes[0].nodeValue;
document.getElementById('ctitle').href = xmlDoc.getElementsByTagName("url")[2].childNodes[0].nodeValue;
document.getElementById("dtitle").innerHTML= xmlDoc.getElementsByTagName("title")[3].childNodes[0].nodeValue;
document.getElementById('dtitle').href = xmlDoc.getElementsByTagName("url")[3].childNodes[0].nodeValue;
document.getElementById("etitle").innerHTML= xmlDoc.getElementsByTagName("title")[4].childNodes[0].nodeValue;
document.getElementById('etitle').href = xmlDoc.getElementsByTagName("url")[4].childNodes[0].nodeValue;
document.getElementById("ftitle").innerHTML= xmlDoc.getElementsByTagName("title")[5].childNodes[0].nodeValue;
document.getElementById('ftitle').href = xmlDoc.getElementsByTagName("url")[5].childNodes[0].nodeValue;
document.getElementById("gtitle").innerHTML= xmlDoc.getElementsByTagName("title")[6].childNodes[0].nodeValue;
document.getElementById('gtitle').href = xmlDoc.getElementsByTagName("url")[6].childNodes[0].nodeValue;
document.getElementById("htitle").innerHTML= xmlDoc.getElementsByTagName("title")[7].childNodes[0].nodeValue;
document.getElementById('htitle').href = xmlDoc.getElementsByTagName("url")[7].childNodes[0].nodeValue;
}
</script>

</head>

<body onLoad="parseXML()">

<!--<div style="position:absolute; top:455px; left:300px">-->

<table border="0" cellpadding="8" cellspacing="0" class id=healthtable height="200" width="350" bordercolor="#C8CECE">
<tr>
<td nowrap="nowrap" background="http://WECT.images.worldnow.com/images/262068_G.png">



<!--<div align="left"><img src="http://WECT.images.worldnow.com/images/261785_G.jpg" width="350" height="25" border="0"></div> -->


<br/>
</b> <a href="" id="atitle"></a><br />
</b> <a href="" id="btitle"></a><br />
</b> <a href="" id="ctitle"></a><br />
</b> <a href="" id="dtitle"></a><br />
</b> <a href="" id="etitle"></a><br />
</b> <a href="" id="ftitle"></a><br />
</b> <a href="" id="gtitle"></a><br />
</b> <a href="" id="htitle"></a><br />
<br/>
<a href="http://www.ivanhoe.com/story/p_newsflash.cfm" target="blank">Click here for more headlines</a>

</div>
</td>
</table>
</tr>
</div>
</body>
</html>