• js,asp 实现读取远程xml


     js 实现读取远程xml
     <script language="JavaScript">
       var xmlDoc=new ActiveXObject("Microsoft.xmlDOM");
       xmlDoc.async=false;
       xmlDoc.load("http://www.donews.com/rss.xml");
       //xmlDoc.loadxml("<description>品格</description>");

       var root=xmlDoc.documentElement;
        var number=root.selectNodes("channel/item").length;

      if(number<=10)
         alert("对不起,该新闻条数已经少于要显示的新闻条数!"); 
      else
       {
          document.writeln("<p align='center' class='font'>"+root.childNodes(0).childNodes(0).text+"<p>");    
          document.writeln("<p class='indent'>"+root.childNodes(0).childNodes(1).text+"</p>");
          document.writeln("<p class='indent'>"+root.childNodes(0).childNodes(2).text+"</p>");
         for(var i=0;i<10;i++)
      {
       document.writeln("<b>"+root.childNodes(0).childNodes(5+i).childNodes(0).text+"</b><br/><br/>");
    document.writeln("<small>"+root.childNodes(0).childNodes(5+i).childNodes(4).text+"&nbsp;&nbsp;&nbsp;&nbsp;"+root.childNodes(0).childNodes(5+i).childNodes(3).text+"</small><br/>");
    document.writeln("<small><a href='"+root.childNodes(0).childNodes(5+i).childNodes(1).text+"'>"+root.childNodes(0).childNodes(5+i).childNodes(1).text+"</a></small><br/><br/>");
    document.writeln("<p class='indent'>"+root.selectNodes("channel/item/description")(i).text+"</p><br/><br/>");
       }
      }
    </script>

     asp 实现读取远程xml文件
    <%
    dim xmlDoc
    dim root
    dim number

    Set http=Server.CreateObject("Microsoft.XMLHTTP")
    http.Open "GET","http://www.donews.com/rss.xml",False
    http.send

    Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
    xmlDoc.Async=False
    xmlDoc.ValidateOnParse=False
    xmlDoc.Load(http.ResponseXML)

    set root=xmlDoc.documentElement
    number=root.selectNodes("channel/item").length

     if number<=10 then
    %>
      <script language="vbscipt">
        msgbox "对不起,该新闻条数已经少于要显示的新闻条数!"
      </script>
    <%
      else
          response.write "<p align='center' class='font'>" & root.childNodes(0).childNodes(0).text & "<p>"    
          response.write "<p class='indent'>" & root.childNodes(0).childNodes(1).text & "</p>"
          response.write "<p class='indent'>" & root.childNodes(0).childNodes(2).text & "</p>"
        for i=0 to 9
       response.write "<b>" & root.childNodes(0).childNodes(5+i).childNodes(0).text & "</b><br/><br/>"
    response.write "<small>" & root.childNodes(0).childNodes(5+i).childNodes(4).text & root.childNodes(0).childNodes(5+i).childNodes(3).text & "</small><br/>"
    response.write "<small><a href='" & root.childNodes(0).childNodes(5+i).childNodes(1).text & "'>" & root.childNodes(0).childNodes(5+i).childNodes(1).text & "</a></small><br/><br/>"
    response.write "<p class='indent'>" & root.selectNodes("channel/item/description")(i).text & "</p><br/><br/>"
      next
      end if
    %>

  • 相关阅读:
    关于Spring和Struts2的整合
    有关Transaction not successfully started问题解决办法
    两种页面跳转
    jdbc连接mysql
    change和modify
    Navicat Premium 15连接Oracle时提示oracle library is not loaded的解决方案
    Oracle创建本地数据库实例及配置监听
    下载Visual Studio 2019离线安装包
    简单的数据库
    未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序
  • 原文地址:https://www.cnblogs.com/winner/p/591243.html
Copyright © 2020-2023  润新知