1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

XML Feed from .ASP pages?

Discussion in 'C#' started by Canton, Mar 2, 2006.

  1. #1
    Bear with me, as I'm not much of a programmer - I always seem to find the "out of the box" solution or manual process to scratch an itch rather than hacking something together.
    Essentially what I want to do is have an XML feed automatically updated each time I update articles on my site.

    Pages are coded in .ASP, though they are not database driven (simply using some basic ASP includes and keeping things native on the site).

    Articles will be posted manually, at least for now, so they are not sitting in a database either.

    Easy solution is to use blogging software to post the articles and let it create the feed, but since I prefer not to do that, I'm coming here to learn what I can - easy solution, out of the box application, free or cheap .ASP scripts somewhere (sticky me if applicable).

    So far, searches of ASP forums and sites hasn't helped...ditto XML-related sites.

    Any thoughts on this, or an easy implementation?

    Technically, since the article creation and posting is quite manual, I could manually update an XML file as well...again, I'd prefer not to.

    Thanks,
    Canton
     
    Canton, Mar 2, 2006 IP
  2. iShopHQ

    iShopHQ Peon

    Messages:
    644
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Without the site being dynamic, I don't see any other way than coding the XML by hand, unless every article you post is formated the same at the code level. Then you could do soemthing like

    www . yoursite . com/article.rss?file=Article.asp

    Then using file system object, open up the file and parse it out using a bunch of replace statement to strip the HTML and replace it with XML.

    I'd doing something similar in my article site. In ISS I configured .rss extensions to be executed as asp pages. the .rss page(s) gets the info out of the database and creates the XML on the fly. Example:

    http://www.freearticlehq.com/ten-newest.asp goes in and pulls the ten newest article info out and creates the asp page on the fly

    http://www.freearticlehq.com/ten-newest.rss goes in and pulls the ten newest article info out and creates the XML, also on the fly
     
    iShopHQ, Mar 9, 2006 IP
  3. FOX LORE

    FOX LORE Notable Member

    Messages:
    8,118
    Likes Received:
    408
    Best Answers:
    0
    Trophy Points:
    230
    #3
    hey can this be done with reviews my site is asp dynamic?
     
    FOX LORE, May 31, 2006 IP
  4. iShopHQ

    iShopHQ Peon

    Messages:
    644
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #4
    sure, can be done... same way I am doing at FreeArticleHQ
     
    iShopHQ, May 31, 2006 IP
  5. FOX LORE

    FOX LORE Notable Member

    Messages:
    8,118
    Likes Received:
    408
    Best Answers:
    0
    Trophy Points:
    230
    #5
    Humm, get you tell me how to code it step by step?
     
    FOX LORE, May 31, 2006 IP
  6. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #6
    
    <%
    strPANURL = "http://www.panarmenian.net/stickers/news/news_eng.rss"
    
    dim xmlDom, nodeCol, oNode, oChildNode
    set xmlDom = Server.CreateObject("MSXML2.Domdocument")
    xmlDOM.async = False
    
    call xmlDom.setProperty("ServerHTTPRequest", true)
    xmlDom.async = false
    call xmlDom.load(strPANURL)
    
    if not xmlDom.documentElement is nothing then
      set nodeCol = xmlDom.documentElement.selectNodes("channel/item")
      i = 1
      for each oNode in nodeCol
        Response.Write("<div class='footer'>" & vbCrLf)
        set oChildNode = oNode.selectSingleNode("pubDate")
        if not oChildNode is nothing then
    		strPubDate = Server.HTMLEncode(oChildNode.text)
    		strPubDate = replace(strPubDate, "&apos;", "&#39;")
    		strPubDate = replace(strPubDate, "&amp;", "&")
    		strPubDate = replace(strPubDate, vbCrLf, "<br>")
          Response.Write("<strong>" & strPubDate & "</strong><br>" & vbCrLf)
        end if
        set oChildNode = oNode.selectSingleNode("link")
        if not oChildNode is nothing then
          Response.Write("  <a href='" & oChildNode.text & "' target='_blank' class='footer' style='color: #CC0000;'>")
    	  strLink = "yes"
        end if
        set oChildNode = oNode.selectSingleNode("title")
        if not oChildNode is nothing then
    		strTitle = Server.HTMLEncode(oChildNode.text)
    		strTitle = replace(strTitle, "&apos;", "&#39;")
    		strTitle = replace(strTitle, "&amp;", "&")
    		strTitle = replace(strTitle, vbCrLf, "<br>")
          Response.Write("" & strTitle & "")
        end if
    	if strLink = "yes" then
          Response.Write("</a><br><br>" & vbCrLf)
    	end if
        'set oChildNode = oNode.selectSingleNode("description")
        'if not oChildNode is nothing then
        '  Response.Write("  " & oChildNode.text & "<br/>" & vbCrLf)
        'end if
    	'if i > 7 then exit for
    	i = i + 1
        Response.Write("</div>" & vbCrLf)
      next
    else
      Response.Write(strPANError & vbCrLf)
    end if
    %>
    
    Code (markup):
     
    ludwig, Jun 1, 2006 IP
  7. iShopHQ

    iShopHQ Peon

    Messages:
    644
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Ludwig:
    He's not looking to consume and show an RSS - he wants to create one.

    fox:
    If you know ASP, you should be able to figure it out. Read my fist post above for the process.

    Configure ISS to execute .rss files as asp
    recode your dynamic asp file to output the page in valid xml format
    validate your feed
    submit it to feedburner

    took me about 8 hours of work over 2 days
     
    iShopHQ, Jun 1, 2006 IP
  8. FOX LORE

    FOX LORE Notable Member

    Messages:
    8,118
    Likes Received:
    408
    Best Answers:
    0
    Trophy Points:
    230
    #8
    O.K. i don't know anything about RSS but i will give it a try..Thanks!
     
    FOX LORE, Jun 1, 2006 IP
  9. mopacfan

    mopacfan Peon

    Messages:
    3,273
    Likes Received:
    164
    Best Answers:
    0
    Trophy Points:
    0
    #9
    This is the code I wrote to publish an rss feed for my site. You'll obviously need to change the title, description, etc. for your site. Good Luck.
    <%@ Language=VBScript %>
    <%
    	function htmlurl(varTxt)
    		s1 = replace(varTxt,"&","&amp;")
    		s2 = replace(s1,"<","&lt;")
    		s3 = replace(s2,">","&gt;")
    		htmlurl = s3
    	end function
    
    	function pubdate(xDate,var)
    		theDay = left(WeekDayName(WeekDay(xDate)),3)
    		theDate = Day(xDate)
    		theMonth = left(MonthName(Month(xDate)),3)
    		theYear = Year(xDate)
    		theHour = Hour(xDate)
    		theMin = Minute(xDate)
    		theSec = Second(xDate)
    
    		select case var
    		case 1 newVar = theDay & ", " & theDate & " " & theMonth & " " & theYear & " " & theHour & ":" & theMin & ":" & theSec & " CST"
    		case 2 newVar =  theDay & ", " & theDate & " " & theMonth & " " & theYear & " 12:00:00 CST"
    		end select
    		pubdate = newVar
    	end function
    	
    	varPD = pubdate(now(),2)
    	Response.AddHeader "Content-Type", "text/html; application/xml"
    %>
    <rss version="2.0">
    	<channel>
    		<title>Project Responder - Content Channel</title>
    		<link>http://www.projectresponder.com</link>
    		<description>Creating the Ultimate Volunteer Firefighter's Emergency Response Vehicle.</description>
    		<language>en-gb</language>
    		<copyright>Copyright 2000-2006 Project Responder, All rights reserved.</copyright>
    		<lastBuildDate><%= varPD %></lastBuildDate>
    		<image>
    			<title>Project Responder</title>
    			<url>http://www.projectresponder.com/images/x/pr-rss-logo.gif</url>
    			<link>http://www.projectresponder.com</link>
    		</image>
    		
    <%
    	Set rssRS = Server.CreateObject("ADODB.Recordset")
    		
    	sql = "SELECT * FROM SiteContent order by DateAdded desc;"	
    	rssRS.Open sql, objConn, 3, 3
    		
    	x=0
    		
    	while not rssRS.eof
    		
    	response.write "        <item>" & vbcrlf
    	response.write "            <title>" & htmlurl(rssRS("title")) & "</title>" & vbcrlf
    	response.write "            <link>http://www.projectresponder.com/content.asp?cid=" & rssRS("ParentID") & "&amp;pid=" & rssRS("autonum") & "</link>" & vbcrlf
    	response.write "            <description>" & htmlurl(rssRS("pagetitle")) & "</description>" & vbcrlf
    	Response.Write "            <pubDate>" & pubdate(rssRS("DateAdded"),2) & "</pubDate>" & vbcrlf
    	response.write "        </item>" & vbcrlf & vbcrlf
    		
    	x=x+1
    		
    	rssRS.movenext
    	wend
    		
    	set rssRS = nothing
    	objConn.close
    	set objConn = nothing
    %>
    	</channel>
    </rss>
    
    Code (markup):
     
    mopacfan, Jun 1, 2006 IP
  10. FOX LORE

    FOX LORE Notable Member

    Messages:
    8,118
    Likes Received:
    408
    Best Answers:
    0
    Trophy Points:
    230
    #10
    Hey,thanks! Need all the Luck i can get...let you know how it turns out.
     
    FOX LORE, Jun 1, 2006 IP
  11. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #11
    well, now you got both, the way to create one and parse one.

    You are lucky, some people don't get what they long for
     
    ludwig, Jun 1, 2006 IP