Javascript reads RSS data

Source: Internet
Author: User

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.