반응형
javascript 로만 구현해 보려 했으나 같은 도메인이 아니면 권한이 문제가 되서 직접 가져올수가 없다
다른곳에서 설명한 방법들도 내용을 보면 proxy 파일을 하나 만들어서 이 문제를 해결하고있다.
결국 서버쪽에서 해결해야 하는 상황이라 찾던중 이런 방법을 찾았다.
<% ' change the RSSURL variable to the exact URL of the RSS Feed you want to pull RSSURL = "http://www.ticketcity.com/rss/Texas-Longhorns-Football-Tickets.rss" Dim objHTTP ' this object is used to call the RSS Feed remotely Dim RSSURL,RSSFeed ' these variables hold the URL and Content for the RSS Feed Dim xmlRSSFeed ' this variable hold the XML data in a DOM Object Dim objItems,objItem, objChild ' these variables are used to temporarily hold data from the various RSS Items Dim title,description,link ' these are local variables that will hold the data to be displayed Dim OutputHTML_1,OutputHTML_2,OutputHTML_3 ' these variables will hold the HTML that was converted from the RSS Feed ' this code requests the raw RSS/XML and saves the response as a stringSet objHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP") objHTTP.open "GET",RSSURL,false objHTTP.send RSSFeed = objHTTP.responseText ' this code takes the raw RSSFeed and loads it into an XML Object Set xmlRSSFeed = Server.CreateObject("MSXML2.DomDocument.4.0") xmlRSSFeed.async = false xmlRSSFeed.LoadXml(RSSFeed) ' this code disposes of the object we called the feed with Set objHTTP = Nothing ' this is where you determine how to display the content from the RSS Feed ' this code grabs all the "items" in the RSS Feed Set objItems = xmlRSSFeed.getElementsByTagName("item") ' this code disposes of the XML object that contained the entire feed Set xmlRSSFeed = Nothing ' loop over all the items in the RSS Feed For x = 0 to objItems.length - 1 ' this code places the content from the various RSS nodes into local variables Set objItem = objItems.item(x) For Each objChild in objItem.childNodes Select Case LCase(objChild.nodeName) Case "title" title = objChild.text Case "link" link = objChild.text Case "description" description = objChild.text End Select Next ' Here are some various display samples. OutputHTML_1 = OutputHTML_1 & "" & title & "
" & description & "
" OutputHTML_2 = OutputHTML_2 & "" & title & "
" OutputHTML_3 = OutputHTML_3 & "" & title & "
" Next %> Here is the output, with content provided by the RSS Feed located at:
<%=RSSURL%>
Ouput Style 1 Ouput Style 2 Ouput Style 3 <%=OutputHTML_1%> <%=OutputHTML_2%> <%=OutputHTML_3%>
출처
http://www.ticketcity.com/our-rss-feeds.html
http://www.bustercollings.com/source-code-samples/rss-asp-classic-source-code-example.asp
반응형
'Story > asp' 카테고리의 다른 글
Mssql To Xml (0) | 2013.03.13 |
---|---|
asp c# .net 에서 mysql password 값을 만들기 (0) | 2013.02.05 |
asp 쿠키(Cookies) 사용 (0) | 2011.02.25 |
asp 특정 아이피(ip)일때 처리 (0) | 2011.02.19 |
asp 에서 " 큰따옴표 사용하기 (0) | 2011.01.28 |