zoukankan      html  css  js  c++  java
  • asp + 读取rss 测试成功两例

    <% @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("对不起,该新闻条数已经少于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>远程读取XML文件</title>
    </head>
    <body>
    <%
    call readrss("http://rss.sina.com.cn/news/allnews/tech.xml")
    %>
    <br><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"    '你要读取的xml文件

    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%"><b>文章名</b></td>
    <td width="20%"><b>发表日期</b></td>
    <td width="40%"><b>分类</b></td>
    </tr>
    <%
    For i=0 to nodeLis.length-1
        If nodeLis(i).selectSingleNode("category") Is Nothing Then Exit For
    %>
    <tr><td colspan=3><font color=red>第 <%=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> 


     

  • 相关阅读:
    canvas直线学习
    移动端页面练习
    IOS 本地推送(UILocalNotification)
    IOS 社交分享
    IOS 通讯录 (访问,添加,修改)
    IOS 蓝牙(GameKit、Core Bluetooth)
    IOS 获取更多的设备信息
    IOS 摇一摇的方法
    IOS Core Motion、UIAccelerometer(加速计使用)
    IOS UIDevice距离传感器(打开 关闭)
  • 原文地址:https://www.cnblogs.com/winner/p/591300.html
Copyright © 2011-2022 走看看