Atom2rss. asp

Source: Internet
Author: User
Tags html encode

Copy codeThe Code is as follows: <%
'Atom2rss. asp
'Author: Francesco Passantino
'Email: francesco@iteam5.net
'Blog: www.iteam5.net/blog
'Start date: 17 Sep 2004

Sub atom2rss (URL)
Set objXML = Server. CreateObject ("msxml2.DOMDocument. 3.0 ")
ObjXML. async = false
ObjXML. setProperty "ServerHTTPRequest", True
ObjXML. validateOnParse = true
ObjXML. preserveWhiteSpace = false

If Not objXML. Load (URL) Then

Response. write "<P> ERROR <br> code :"&_
ObjXML. parseError. errorCode &_
"<Br> Linea/Col :"&_
ObjXML. parseError. line &"/"&_
ObjXML. parseError. linepos & "</P>"

Else

Rsstitle = "iteam5.net/blog"
Rssdescription = "Blog sulle novit? Del settore Information & Communication Technologies"
Rsslink = "http://www.iteam5.net/blog"
Rsslanguage = "it"

Xml = "<? Xml version = "" 1.0 "" encoding = "" UTF-8 ""?> <Rss version = "0.91" "> <channel> <title>" &server.html encode (rsstitle) & "</title> <description>" &server.html encode (rssdescription) & "</description> <link>" &server.html encode (rsslink) & "</link> <language>" &server.html encode (rsslanguage) & "</language>"

Set objNodeList = objXML. getElementsByTagName ("entry ")
For Each objNode In objNodeList
For Each objNode2 In objNode. childNodes

Select Case objNode2.nodeName
Case "issued"
Strdate = left (objNode2.firstChild. nodevalue, 10)
Case "link"
StrURL = objNode2.GetAttribute ("href ")
Case "title"
StrTitle = objNode2.firstChild. nodevalue

'Instead of Case "content"
Case "summary"

StrDescription = objNode2.firstChild. data
For Each objNode3 In objNode2.childNodes
Select Case objNode3.nodeName
Case "div"
StrDescription = objNode3.text
For Each objNode4 In objNode3.childNodes
Select Case objNode4.nodeName
Case ""
Linkable = objNode4.firstChild. text
Htmlink = "<a href = '"&_
ObjNode4.GetAttribute ("href") & "'> "&_
Linkable & "</a>"
StrDescription = replace (StrDescription, linkable, htmlink)
End select
Next
End select
Next
End Select
Next

Xml = xml & "<item>"
Xml = xml & "<title> <! [CDATA ["& server.html encode (strTitle) &"]> </title>"
Xml = xml & "<description> <! [CDATA ["& server.html encode (strDescription) &"]> </description>"
Xml = xml & "<link> <! [CDATA ["& server.html encode (strURL) &"]> </link> </item>"

StrTitle = ""
StrURL = ""
StrDescription = ""

Next

Xml = xml & "</channel> </rss>"
Response. ContentType = "text/xml"
Response. write xml

Set objNodeList = Nothing

End if
End sub

Call atom2rss ("http://www.iteam5.net/blog/feed.xml ")

%>

Related Article

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.