Two successful ASP + RSS reading tests

Source: Internet
Author: User

<% @ Language = "VBScript" %>

<%
Function readrss (xmlseed)
Dim xmldoc
Dim HTTP
Set HTTP = server. Createobject ("Microsoft. XMLHTTP ")
HTTP. Open "get", xmlseed, false
HTTP. Send
Set xmldoc = server. Createobject ("Microsoft. xmldom ")
Xmldoc. async = false
Xmldoc. validateonparse = false
Xmldoc. Load (HTTP. responsexml)
Set item = xmldoc. getelementsbytagname ("item ")
If item. Length <= 10 then
%>
<Script language = "JavaScript">
Alert ("sorry, the number of news lines is already less than 10! ");
</SCRIPT>
<%
Else
For I = 0 to (item. Length-1)
Set Title = item. Item (I). getelementsbytagname ("title ")
Set link = item. Item (I). getelementsbytagname ("Link ")
Response. write ("<a href =" "& link. item (0 ). text & "target = '_ blank'>" & title. item (0 ). text & "</a> <br> ")
Next
End if
End Function
%>
<HTML>
<Head>
<Title> remote XML file reading </title>
</Head>
<Body>
<%
Call readrss ("http://rss.sina.com.cn/news/allnews/tech.xml ")
%>
<Br>
<%
Call readrss ("http://rss.sina.com.cn/news/allnews/astro.xml ")
%>
</Body>
</Html>

========================================================== ==============================================

<HTML>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> Read XML </title>
<Body>
<%
Dim xmlurl
Xmlurl = "http://rss.sina.com.cn/news/allnews/tech.xml" 'the XML file you want to read

Dim HTTP
Dim node, I, nodecount
Set HTTP = server. Createobject ("msxml2.xmlhttp ")
HTTP. Open "get", xmlurl, false
HTTP. Send
Set Doc = server. Createobject ("Microsoft. xmldom ")
Doc. async = false
Doc. validateonparse = false
Doc. Load (HTTP. responsexml)
Set nodelis = Doc. getelementsbytagname ("item ")
%>
<Table border = "0" width = "80%" align = "center">
<Tr>
<TD width = "40%" type = "codeph" text = "codeph"> <B> Article Name </B> </TD>
<TD width = "20%"> <B> publication date </B> </TD>
<TD width = "40%"> <B> Category </B> </TD>
</Tr>
<%
For I = 0 to nodelis. Length-1
If nodelis (I). selectsinglenode ("category") is nothing then exit
%>
<Tr> <TD colspan = 3> <font color = Red> record <% = I + 1%>: </font> </TD> </tr>
<Tr>
<TD>
<% = Nodelis (I). selectsinglenode ("title"). Text %>
</TD>
<TD>
<% = Nodelis (I). selectsinglenode ("category"). Text %>
</TD>
<TD>
<% = Nodelis (I). selectsinglenode ("pubdate"). Text %>
</TD>
</Tr>
<%
Next
Set Doc = nothing
%>
</Table>
</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.