HAL-PC Web Technolgies SIG

Mail List | SIG Leader

ASP display of RDF or XML feeds

HAL-PC Web Technologies SIG

I modified the VB script from http://www.freevbcode.com/ShowCode.Asp?ID=5665 to display in a CSS format instead of the default table format so that it displays in the box on the left instead of in a large table.

Infoworld recent headlines

Motive gives single view of distributed apps
An emerging trend in application management software is the capability to view distributed applications, deployed on many tiers, as a single entity. Putting the new approach to work, management software vendor Motive will launch three products to help manage distributed applications: Motive Profile, Motive Triage, and Motive Resolution.

Trilog eases Domino to Java transition
Trilog Group this week rolled out an integrated J2EE development framework designed to let IBM Lotus Notes developers use their existing skills for J2EE development projects.

Oracle and IBM move BPEL to the BPI forefront
Breaking down business processes into Web services components was the easy part. Weaving them together into manageable, useful services has proved more ambitious.

The human information filter
In last week’s column, I mentioned del.icio.us, Joshua Schachter’s “social bookmarking” service. Since then, I’ve explored the service more deeply in a series of blog entries. Using del.icio.us, I’m now able to process information in dramatically more efficient ways. Let’s look at some of the reasons why.

Yahoo's legal battle over Nazi items continues
PARIS - Yahoo Inc. may after all find itself having to answer to the French courts for its failure to block French users' access to information about the sale of Nazi memorabilia on its U.S. Web sites.

ADVERTISEMENT

SBC Case Study: Crate & Barrel
What sold them on improving their network? A system that could cut management costs from the get-go. Find out more.

Portals, news sites, must improve customer satisfaction
As far as keeping their customers satisfied, Web portals, search engines, and news and information sites in the U.S. continue to improve but still have work to do, according to a report released Tuesday.

WS-I tackles Web services attachments
The Web Services Interoperability Organization (WS-I) on Tuesday is releasing three profiles intended to make it easier to send attachments using Web services technologies.

ECM wares seize control of records creation, management
Under the shadow of government regulations IT must comply with, a host of ECM (enterprise content management) vendors are blending previously stand-alone RM (records management) capabilities into their CM and compliance recipes.

BEA readies app server package for ISVs
BEA Systems on Monday is releasing a version of its application infrastructure suite designed to enable ISVs to deliver products for SOAs (service-oriented architectures).

Macromedia launches Flex Builder
Macromedia this week will ship Flex Builder, which is designed to provide an interactive development environment for the company’s Flex presentation server.


Unfortunately, this method does not works with RSS feeds that use a php extension for their XML files such as the Lockergnome Webmaster Weekly. The code as I have modified it is below:

* I need to clarify that it will work with the Lockergnome feed but since itincludes the full content you can't use a small box on the side like I did with the InfoWorld Feed

<%
bUseApp = false 'set to true if you
'want to cache responses in memory
'(Application variable) rather than
'file.

function ReplaceMultiple(InputString, CharsToReplace)
iCount = len(CharsToReplace)
sTemp = InputString
for iCtr = 1 to iCount
sChar = mid(CharsToReplace, iCtr, 1)
sTemp = replace(sTemp, sChar, "")

Next
ReplaceMultiple = sTemp
End Function
function WriteToFile(FileName, Contents)

iMode = 2 'overwrite
set oFs = server.createobject("Scripting.FileSystemObject")
set oTextFile = oFs.OpenTextFile(FileName, 2, True)
oTextFile.Write Contents
oTextFile.Close
set oTextFile = nothing
set oFS = nothing

end function

Private Function ReadTextFile(fName)
set oFs = server.createobject("Scripting.FileSystemObject")
If oFs.FileExists(fName) Then
Set FSTR = ofs.OpenTextFile(fName)
ReadTextFile = FSTR.ReadAll
FSTR.Close
Set FSTR = Nothing
Set FSO = Nothing
end if
End Function

Private Function ReadAppVariable(fName)
ReadAppVariable = Application(fName)
End Function
Private Function WriteAppVariable(FileName, Contents, RSSURL)

Application.lock
Application(FileName) = contents
Application(RSSURL) = Hour(now)
Application.unlock
end function

Function DisplayRSSFeed(RSSURL, FeedName)
'caches the feed, updates every hour, uses a file cache
'if it hasn't been update in an hour or running for the first time
'get it and save from file,
'else read it from file

Set objXML = Server.CreateObject("MSXML2.DOMDocument")
objXML.async = False
'necessary because MSXML
'doesn't seem to work very well
'when an external DTD is referred to
objXML.validateOnParse = false
objXML.resolveExternals = false

iPos = InstrRev(RSSURL, "/")
if iPos = 0 then
sFileName = RSSURL
else
sFileName = mid(RSSURL, iPos + 1)
end if
sFileName = FeedName & "_" & sFileName & ".xml"
'remove invalid/unwanted chars
sFileName = ReplaceMultiple(sFileName,"[]/\\(^+)$,)?&:=")
sFileName = Server.MapPath(".") & "\" & sFileName

if Application(RSSURL) <> Hour(Now) then

set objXMLHTTP = Server.CreateObject("MSXML2.SERVERXMLHTTP")
objXMLHTTP.Open "GET", RSSURL, false

objXMLHTTP.SetRequestHeader "Content-type", "text/html"
on error resume next
objXMLHTTP.Send
sAns = objXMLHTTP.ResponseText
on error goto 0

set objXMLHTTP = nothing

'Ensure you have a valid XML response
bAns = objXML.loadXML(sAns)
if bAns = true then
'save to file
'Requires ASP user has write permissions to'
'path you use
if bUseApp = false then
WriteToFile sFileName, sAns
Application.Lock
'refresh in an hour
Application(RSSURL) = Hour(now)
Application.unlock
else
WriteAppVariable sFileName, sAns, RSSURL
end if

else 'if invalid, try using a previous version
'response.write "Loading from file " & sFileName & " due to failure"
if bUseApp = false then
sContents = ReadTextFile(sFileName)
else
sContents = ReadAppVariable(sFileName)
end if

bAns = objXML.loadXML(sContents)
'bAns = objXML.load(sFileName)
end if
else 'try to load from cache on failure to refresh
if bUseApp= false then
sContents = ReadTextFile(sFileName)
else
sContents = ReadAppVariable(sFileName)
end if
bAns = objXML.loadXML(sContents)

End if

if bAns then

'RSS implementations vary. Some use item as a child of channel
'some don't
'that is what the below is about

'rss .9x and 2.0 implementation
set objItemNodes = objXML.DocumentElement.SelectNodes("item")

if objItemNodes.length = 0 then
'rss 1.x implemenation
set objItemNodes = _
objXML.DocumentElement.SelectSingleNode("channel").SelectNodes("item")
end if

'display inside css div with contextual selectors

response.write "<h4>" & FeedName & " recent headlines</h4>"
for each oNode in objItemNodes

sLink = oNode.selectSingleNode("link").Text
set oDescriptionNode = oNode.selectSingleNode("description")
if not oDescriptionNode is nothing then
sDesc= oDescriptionNode.Text
else
sDesc = ""
end if
sTitle = oNode.selectSingleNode("title").Text
response.write "<p><a href ='" & sLink & "'>" & sTitle & _
"</a><br />"
response.write sDesc & "</p>"

next
response.write "<br />"

else

response.write "The requested feed is not available"

end if
set oNode = Nothing
set objItemNodes = Nothing
set objXML = Nothing
End function
'DEMO
DisplayRSSFeed "http://www.infoworld.com/rss/webservices.rdf", "Infoworld"
response.write "<p>"
'DisplayRSSFeed "http://boingboing.net/rss.xml", "Boing Boing Blog"
'response.write "<p>"

%>

About Us | Site Map | Advanced Search | Privacy Policy | Contact Us | ©1999-2006 HAL-PC Web Technologies SIG Leader Cheryl D. Wise