Copy codeThe Code is as follows:
<Html>
<Head>
<Title> javascript reads RSS data </title>
<META content = "text/html; charset = UTF-8" http-equiv = Content-Type/>
</Head>
<Body leftmargin = "0" topmargin = "0">
<Font>
<Br>
<Table width = "90%" align = "center" border = "0" cellpadding = 0 cellspacing = 0>
<Tr>
<Td bgcolor = White> <B> News Center </B> <font size = "-1"> (from Sina) </font> </Tr>
<Tr>
<Td bgcolor = White>
<Div id = "container"> News Loading... </div>
</Td>
</Tr>
</Table>
<Script language = "JavaScript1.2">
// Container for ticker. Modify its STYLE attribute to customize style:
Var tickercontainer =''
Var xmlsource = "http://rss.mydrivers.com/Fitting_News.xml ";
Var root;
Var title;
Var link;
Var items;
Var item;
Var images;
Var image;
Var description;
If (window. ActiveXObject)
{
// Document. write ("Microsoft. XMLDOM ");
Var xmlDoc = new ActiveXObject ("Microsoft. XMLDOM ");
}
Else if (document. implementation & document. implementation. createDocument)
{
// Document. write ("document. implementation. createDocument ");
Var xmlDoc = document. implementation. createDocument ("", "doc", null );
}
If (typeof xmlDoc! = "Undefined ")
{
// Document. write (tickercontainer)
XmlDoc. load (xmlsource)
}
Function fetchxml ()
{
If (xmlDoc. readyState = 4)
Output ()
Else
SetTimeout ("fetchxml ()", 10)
}
Function output ()
{
Var temp = "";
Root = xmlDoc. getElementsByTagName ("channel") [0];
Title = root. getElementsByTagName ("title") [0];
// Temp = title. firstChild. nodeValue + "<br> ";
Items = root. getElementsByTagName ("item ");
For (I = 0; I <= items. length-1; I ++)
{
Item = items [I];
Title = item. getElementsByTagName ("title") [0];
Link = item. getElementsByTagName ("link") [0];
Description = item. getElementsByTagName ("description") [0];
Temp = temp + "<font size =-1> <a href =" + link. firstChild. nodeValue + "target = '_ bank'>" + title. firstChild. nodeValue + "</a> </font> <br> ";
// Temp = temp + "<font size =-1>" + description. firstChild. nodeValue + "</font> <br> ";
Document. getElementById ("container"). innerHTML = temp;
}
}
If (window. ActiveXObject)
Fetchxml ()
Else if (typeof xmlDoc! = "Undefined ")
XmlDoc. onload = output
</Script>
</Body>
</Html>