国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
在ASP中使用RSS

RSS跟一般的XML文件一樣,必須使用XSL文件來(lái)定義其中的標(biāo)籤。

RSS的架構(gòu)太簡(jiǎn)單,自己寫也沒(méi)什麼意思,教學(xué)中這支程式是網(wǎng)路上流傳的rss閱讀程式,大家直接抓回去用就好了。

首先,我們必須先寫一份XSL文件來(lái)定義RSS中的標(biāo)籤。

一份RSS文件的基本架構(gòu)如下:

<rss version="2.0">
 <channel>
  <title>文件抬頭</title>
  <link>文件網(wǎng)址</link>
  <description>文件簡(jiǎn)介</description>
  <language>zh-tw(文件語(yǔ)言,zh-tw是臺(tái)灣的傳統(tǒng)中文)</language>
  <lastBuildDate>Sat, 26 Nov 2005 11:40:19 GMT(建立時(shí)間)</lastBuildDate>
  

  <item>
   <title>項(xiàng)目標(biāo)題</title>
   <link>項(xiàng)目連結(jié)</link>
   <pubDate>項(xiàng)目更新日期</pubDate>
  </item>

  <item>
   <title>項(xiàng)目標(biāo)題</title>
   <link>項(xiàng)目連結(jié)</link>
   <pubDate>項(xiàng)目更新日期</pubDate>
  </item>
...
 </channel>
</rss>

 


rss標(biāo)籤代表的是文件主體;channel則是文件內(nèi)容;channel下的title、link、description則分別是這份rss希望顯示的抬頭、官方網(wǎng)站連結(jié)和簡(jiǎn)介;item標(biāo)籤rss文件中的單一項(xiàng)目:每個(gè)項(xiàng)目也都可以定義抬頭、項(xiàng)目項(xiàng)目的位址和更新日期等。

我們可以建立一份對(duì)應(yīng)rss架構(gòu)的xsl文件,xsl文件內(nèi)容如下:

<?xml version="1.0" ?>
 <xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:output method="xml" encoding="big5" omit-xml-declaration="yes" indent="yes"/>
 <xsl:template match="*">
  <table border="1" width="600" align="center" style="border-collapse:collapse" cellpadding="5">
  <tr>
   <td valign="top" class="title" bgcolor="#336699">
    <a>
     <xsl:attribute name="href">
     <xsl:value-of select="*[local-name()='channel']/*[local-name()='link']"/>
     </xsl:attribute>
     <xsl:attribute name="target">
     <xsl:text>top</xsl:text>
     </xsl:attribute>
     <font color="#ffffff">
     <xsl:value-of select="*[local-name()='channel']/*[local-name()='title']" disable-output-escaping="yes"/>
     </font>
    </a>
    <font color="#ffffff">
     <xsl:text disable-output-escaping="yes"> </xsl:text>
     <xsl:value-of select="*[local-name()='channel']/*[local-name()='lastBuildDate']"/>
    </font>
   </td>
  </tr>
  <tr>
   <td valign="top" bgcolor="#eeeeee" class="headlines" > 
    <xsl:for-each select="http://*[local-name()='item']">
     <p>
     <a>
      <xsl:attribute name="href">
      <xsl:value-of select="*[local-name()='link']"/>
      </xsl:attribute>
      <xsl:attribute name="target">
      <xsl:text>top</xsl:text>
      </xsl:attribute>
      <xsl:value-of select="*[local-name()='title']" disable-output-escaping="yes"/>
     </a>
     <xsl:text disable-output-escaping="yes"> </xsl:text>
     <xsl:value-of select="*[local-name()='description']" disable-output-escaping="yes"/>
     </p>
    </xsl:for-each>
   </td>
  </tr>
  </table>
 </xsl:template>
 <xsl:template match="/">
 <xsl:apply-templates/>
 </xsl:template>
</xsl:stylesheet>

 


這份xsl文件將xml標(biāo)籤中含有的屬性和數(shù)值整理成為一個(gè)表格,若看不懂你可參考一下酷必網(wǎng)其他的XML教學(xué)。

接著當(dāng)然就是要建立一個(gè)能夠存取rss文件的函式,這部份可以直接用微軟XML Parser來(lái)達(dá)成:

<%
Sub getXML(sourceFile)
     dim styleFile
     dim source, style
     styleFile = Server.MapPath("news.xsl") '你的XSL文件檔名

     set source = Server.CreateObject("Msxml2.DomDocument")
     source.async = false
     source.setProperty "ServerHTTPRequest", true
     source.load CStr(sourceFile)

     set style = Server.CreateObject("Msxml2.DomDocument")
     style.async = false
     style.load styleFile

     source.transformNodeToObject style, Response
     set source = nothing
     set style = nothing
End Sub
%>

 

這個(gè)函式很容易使用,只要將RSS文件的網(wǎng)址作為函式參數(shù)就行了:

<% getXML("

 

上例是奇摩的政治新聞版的rss文件。

通常網(wǎng)路上的站臺(tái)若有提供rss,都會(huì)有個(gè)橘色的rss圖案連結(jié)到與該頁(yè)有關(guān)的rss文件。就拿奇摩新聞來(lái)說(shuō)好了,每一頁(yè)的rss圖案連結(jié)到的就是含有該頁(yè)最新新聞列表的rss文件。

很容易吧!

打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
如何做外鏈
實(shí)現(xiàn)讀取RSS 2.0的Javascript類
RSS 2.0 Specification參考手冊(cè)
RSS制作(C#) - 使用XML DOM和XmlTextWriter(見(jiàn)評(píng)論)兩種方法 - 不做懶人 - 博客園
XML復(fù)習(xí)題
rss訂閱 40709020112西航
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服