[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Aggregate numerous RSS feeds into a single xml file, reorder by most recent and display 6

Posted on 2007-07-30
4
Medium Priority
?
464 Views
Last Modified: 2013-11-18
I am trying to create an xml file made from various RSS feeds in order by most recent. I plan on accessing this master xml file to display 6 most recent blog entries. At the moment it's dynamic (an xslt reorders by date posted and displays only 6)  but with 17 blogs being read it's slowing down the page that's loading them.

I would like to aggregate all 17 blogs to a single xml file and have a cron job run the asp file that generates the file. In a perfect world it would reorder them and display only 6.

Here is what I have for my dynamic feed written in classic ASP. How do I make it write to a file?

<%
Set xslDoc = Server.CreateObject("MSXML2.DomDocument.4.0")
xslDoc.async = false
xslDoc.load(Server.MapPath("feedTransform.xslt"))

Set xmlFeedlist = Server.CreateObject("MSXML2.DomDocument.4.0")
Set oRoot = xmlFeedlist.createElement("rss")
oRoot.setAttribute "version", "2.0"
xmlFeedlist.appendChild(oRoot)

'load feed 1
Set xmlFeed1 = Server.CreateObject("MSXML2.DomDocument.4.0")
xmlFeed1.async = false
xmlFeed1.Load(getXmlFeed("http://xx.com/index.xml"))
If Not xmlFeed1.documentElement Is Nothing Then
     oRoot.appendChild(xmlFeed1.documentElement.childNodes(0).cloneNode(true))
End if


'load feed 2
Set xmlFeed2 = Server.CreateObject("MSXML2.DomDocument.4.0")
xmlFeed2.async = false
xmlFeed2.Load(getXmlFeed("http://xx.com/index.xml"))
If Not xmlFeed2.documentElement Is Nothing Then
     ' We want the channel node, which is the child of the root element
     oRoot.appendChild(xmlFeed2.documentElement.childNodes(0).cloneNode(true))
End if

function getXmlFeed(sUrl)

     Dim oXMLHttp
     Dim oADORec
     Dim sXML

      Set oXMLHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
      oXMLHttp.open "GET", sUrl, false
    oXMLHttp.send() ' Send the request.
      
      
      getXmlFeed = oXMLHttp.ResponseBody
      
      set oXMLHttp = nothing

End function

xmlFeedlist.transformNodeToObject xslDoc, response

Set oRoot = nothing
Set xslDoc = nothing
Set xmlFeedlist = nothing
Set xmlFeed1 = nothing
Set xmlFeed2 = nothing


function getXmlFeed(sUrl)

       Dim oXMLHttp
     Dim oADORec
     Dim sXML

      Set oXMLHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
      oXMLHttp.open "GET", sUrl, false
    oXMLHttp.send() ' Send the request.
      
      
      getXmlFeed = oXMLHttp.ResponseBody
      
      set oXMLHttp = nothing

End function

%>

thanks!
aenders
0
Comment
Question by:aenders
  • 2
  • 2
4 Comments
 
LVL 8

Expert Comment

by:jawahar_prasad
ID: 19606581
Hi..
To write to a file
http://www.expertsforge.com/Web-Development/Tutorial-9.asp

Similar way u can write to .xml file in your server... Your asp page can call this xml file
0
 

Author Comment

by:aenders
ID: 19611565
Thanks, but I was looking for help on incorporating it into the code above.
0
 

Author Comment

by:aenders
ID: 19758482
Sorry, went away on vacation.

I see in the tutorial how to write to a file by entering text, but how do I get the xml feed to write to file. I can write to a file by sending it text, but how do I get the aggregated xml to write to file?

I tried:

Dim objFSO, objTextFile

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile(Server.MapPath("blogfeeds.xml"))

objTextFile.Write(xmlFeedlist.transformNodeToObject(xsl))
objTextFile.Close


Set objTextFile = Nothing
Set objFSO = Nothing


I get this error: Type mismatch: 'xmlFeedlist.transformNodeToObject'

Thank you!
aenders
0
 
LVL 8

Accepted Solution

by:
jawahar_prasad earned 1500 total points
ID: 19911571
you should write all the xml data into a file and then write it to a file..

example...

Dim objFSO, objTextFile
xmldata="<channel><data>some data</data></channel>

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile(Server.MapPath("blogfeeds.xml"))

objTextFile.Write(xmldata)
objTextFile.Close


Set objTextFile = Nothing
Set objFSO = Nothing

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question