Solved

pubDate from WordPress RSS feed won't display on my asp page

Posted on 2008-10-29
5
1,063 Views
Last Modified: 2013-11-18
We have recently set up a WordPress blog in order to use the RSS feed to display news items on our asp webpage. I am using a bit of code we have used previously (and successfully) to display RSS feeds. However, the pubDate from the RSS feed will not display in any format - I can't seem to get it to write out anywhere on the page. The attached code contains 2 feeds - RSS1 is a feed of training events that works; RSS2 is the WordPress feed that isn't working.
<%

' =========== configuration for rolling box feeds=====================

' ##### URL to RSS Feed to display #########

URLToRSS1 = "http://ittraining.lse.ac.uk/xml/staffittraining.xml"

URLToRSS2 = "http://lseitnews.wordpress.com/feed/"
 

' ##### max number of displayed items #####

MaxNumberOfItems = 5

' ##### Item template.

' ##### {LINK} will be replaced with item link

' ##### {TITLE} will be replaced with item title

' ##### {DESCRIPTION} will be replaced with item description

' ##### {PUBDATE} will be replaced with date published

TrainingItemTemplate = "<p>{TITLE}<BR></p>"

ItemTemplate = "<p><em>{PUBDATE}</em><br /><strong>{TITLE}</strong><br /><em><a href=" & """{LINK}""" & " target='blank'>read more...</a></em><BR /></p>"
 

' ================================================
 

' =========== function to convert date=====================

 function convert(date)

 dim datearray

 date=left(date,10)

 datearray= split (date,"-")

 yearstr=datearray(0)

 monthstr=datearray(1)

 daystr=datearray(2)

 

 convert=Cdate(daystr &"/"& monthstr &"/"& yearstr)

 end function
 

'==========================================================

Set xmlHttp1 = Server.CreateObject("MSXML2.XMLHTTP.3.0")

Set xmlHttp2 = Server.CreateObject("MSXML2.XMLHTTP.3.0")
 
 

xmlHttp1.Open "Get", URLToRSS1, false

xmlHttp1.Send()

RSSXML1 = xmlHttp1.ResponseText

xmlHttp2.Open "Get", URLToRSS2, false

xmlHttp2.Send()

RSSXML2 = xmlHttp2.ResponseText
 

Set xmlDOM1 = Server.CreateObject("MSXML2.DomDocument.3.0")

Set xmlHttp2 = Nothing ' clear HTTP object
 

xmlDOM1.async = false

xmlDOM1.LoadXml(RSSXML1)

Set xmlDOM2 = Server.CreateObject("MSXML2.DomDocument.3.0")

xmlDOM2.async = false

xmlDOM2.LoadXml(RSSXML2)
 

Set xmlHttp1 = Nothing ' clear HTTP object

Set xmlHttp2 = Nothing ' clear HTTP object
 

Set RSSItems1 = xmlDOM1.getElementsByTagName("item") ' collect all "items" from downloaded RSS

Set xmlDOM1 = Nothing ' clear XML

Set RSSItems2 = xmlDOM2.getElementsByTagName("item") ' collect all "items" from downloaded RSS

Set xmlDOM2 = Nothing ' clear XML
 

RSSItemsCount1 = RSSItems1.Length-1

RSSItemsCount2 = RSSItems2.Length-1
 

j = -1

k = -1

%>
 
 
 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML lang=en>

<HEAD><TITLE>IT Services</TITLE>

<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">

<LINK media=screen href="http://www.lse.ac.uk/css/lse-strict.css" type=text/css rel=stylesheet>

<LINK media=screen href="http://www.lse.ac.uk/css/v3/itservices.css"type=text/css rel=stylesheet>

<base href="http://www.lse.ac.uk/itservices/" />

</HEAD>
 
 

<BODY>

<TABLE class=template-maintable cellSpacing=0 cellPadding=0 align=center summary="" border=0>

<TBODY> 

<TR>

<TD class=template-header><img src="http://www.lse.ac.uk/images/v3/itservices/header.jpg" alt="London School of Economics and Political Science" width="748" height="106"></TD>

</TR>
 

<TR>

<TD class=template-backgroundimage>

<TABLE class=template-secondarytable cellSpacing=0 cellPadding=0 width="920" align=center summary="" border=0>

<TBODY>

<TR>

<TD colSpan=7><IMG height=6 alt="" src="http://www.lse.ac.uk/images/v3/itservices/spacer.gif" width=3></TD></TR>

<TR>

<TD class=template-firstgutter><IMG height=3 alt="" src="http://www.lse.ac.uk/images/v3/itservices/spacer.gif" width=6></TD>
 

<!--Start of Left menu -->
 

<TD class=template-leftmenu vAlign=top>
 
 

<!--End of navigation boxes -->
 

<TABLE cellSpacing=0 cellPadding=0 width="100%" summary="" border=0><TBODY>

<TR>

<TD><IMG height=1 alt="" src="http://www.lse.ac.uk/images/v3/itservices/190line.gif" width=190></TD></TR></TBODY></TABLE>
 

<TABLE cellSpacing=0 cellPadding=5 width="100%" summary="" border=0><TBODY>

<TR>

<TD class=template-leftmenuindex><P class=template-margin-zero>

 <A href="http://www.lse.ac.uk/resources/siteIndex/">A-Z site index</A></P>

 </TD></TR></TBODY></TABLE>

            

<TABLE cellSpacing=0 cellPadding=0 width="100%" summary="" border=0><TBODY>

<TR>

<TD><IMG height=1 alt="" src="http://www.lse.ac.uk/images/v3/itservices/190line.gif" width=190></TD></TR></TBODY></TABLE>
 

<!--this is the search form start -->

<form method="GET" action="http://search.lse.ac.uk/search" name="searchForm" class="template-leftmenuindex">

              <div class="template-formmenuitem">

                <table cellspacing="0" cellpadding="5" border="0" summary>

                  <tr>

                    <td>

                      <input type="text" name="q" id="q" maxlength="256" value="Search" onFocus="this.value=''" size="20"></td>

                    <td class="nudge"><input type="image" src="http://www.lse.ac.uk/images/v3/itservices/go_button.gif" alt="GO" width="20" height="17"></td>

                  </tr>

                </table>

              </div>

              

<TABLE cellSpacing=0 cellPadding=0 width="100%" summary="" border=0><TBODY>

<TR>

<TD><IMG height=1 alt="" src="http://www.lse.ac.uk/images/v3/itservices/190line.gif" width=190></TD></TR></TBODY></TABLE>

<TABLE cellSpacing=0 cellPadding=5 width="100%" summary="" border=0><TBODY>

<TR>

<TD class=template-leftmenuindex>

<P class=small><input type="radio" value="" name="site">LSE</P></TD>

<TD class=template-leftmenuindex>

<p class="small"><input type="radio" value="itServices" checked="checked" name="site">IT Services</TD></TR></TBODY></TABLE>

<!--<input type="hidden" name="site" value="systest"> this hidden value is overridden/replaced by the 'site' radio button group-->

              <input type="hidden" name="output" value="xml_no_dtd">

              <input type="hidden" name="client" value="systest">

              <input type="hidden" name="proxystylesheet" value="systest">
 

</form>
 

<!--this is the search form end -->
 
 

<!--End of left column -->
 
 
 
 

<TD class=template-secondgutter><IMG height=3 alt="" src="http://www.lse.ac.uk/images/v3/itservices/spacer.gif" width=6></TD>

<!--Content area -->
 

<TD class=template-contentarea vAlign=top width="938"><A name=body></A>

            <H1 class=template-margin-top-zero>

            &nbsp;IT 

			Services</H1>

            <table width="98%" cellspacing="4" bordercolor="#808080" style="border-collapse: collapse" cellpadding="0">

              <tr>

                <td width="49%" valign="top" style="border-right-style: none; border-right-width: medium">

                &nbsp;</td>

                <td width="2%" valign="top" rowspan="2" style="border-left-style: solid; border-left-width: 1; border-right-style: none; border-right-width: medium">&nbsp;</td>

                <td width="49%" valign="top" rowspan="2" style="border-left-style: none; border-left-width: medium">

                <p class="big"><b>Latest news</b> </p>

                  <p>

                  

                  

                  <!--START OF NEWS FEED -->
 

<%                  

Number_of_Stories=0

For i = 0 To RSSItemsCount2
 

Set RSSItem2 = RSSItems2.Item(i)

		for each child in RSSItem2.childNodes

			Select case lcase(child.nodeName)

			case "title"

			RSStitle = child.text

			case "link"

			RSSlink = child.text

			case "pubDate" 

			RSSpubdate = child.text

			End Select

		next
 

 

'testing converting the date

'published=Rsspubdate

k = k+1

 	if k<MaxNumberOfItems then 

 		'if published > date - 1 and published < date + 7 then

		ItemContent = Replace(ItemTemplate,"{LINK}",RSSlink)

		ItemContent = Replace(ItemContent,"{PUBDATE}",FormatDateTime(RSSpubdate))

		ItemContent = Replace(ItemContent,"{TITLE}",RSSTitle)

		Response.Write ItemContent

		ItemContent = ""

		Number_of_Stories = Number_of_Stories + 1

		'end if

	End if

Next

%>
 
 

<!--END OF NEWS FEED -->

</p>

				<p>&nbsp;</p>

                  </td>

              </tr>

              <tr>

                <td width="49%" valign="top" style="border-right-style: none; border-right-width: medium">

                &nbsp;</td>

              </tr>

            </table>            

            <hr>

            <hr>

            <table width="100%" cellpadding="15" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">

              <tr>

                <td width="187" valign="top">

                <h4><strong>Free training courses running in the next 7 days</strong></h4>

                <p>

                <%

                      

                     

Number_of_Courses=0

For i = 0 To RSSItemsCount1
 

Set RSSItem1 = RSSItems1.Item(i)

		for each child in RSSItem1.childNodes

			Select case lcase(child.nodeName)

			case "title"

			RSStitle = child.text

			case "link"

			RSSlink = child.text

			case "ev:startdate"

			RSSstartdate=child.text

			End Select

		next
 

 

'testing converting the date

startdate=convert(Rssstartdate)

j = J+1

 	if J<MaxNumberOfItems then 

		if startdate > date and startdate < date + 7 then

		ItemContent = Replace(TrainingItemTemplate,"{LINK}",RSSlink)

		ItemContent = Replace(ItemContent,"{TITLE}",RSSTitle)

		Response.Write ItemContent

		ItemContent = ""

		Number_of_Courses = Number_of_Courses + 1

		end if

	End if

Next
 
 

'Response.End ' uncomment this line if you need to finalize output

%>

                </p>                  

                  <p align="right"><i><a href="http://ittraining.lse.ac.uk">course booking and more 

                  training options...</a></i></p>                  

                    </td>

                <td valign="top" bgcolor="#D2D9DE" width="187">

                &nbsp;</td>

              </tr>

            </table>

            <P> &nbsp;</p>
 

</TD>
 
 
 
 

<TD class=template-thirdgutter width="6"><IMG height=3 alt="" src="http://www.lse.ac.uk/images/v3/itservices/spacer.gif" width=6></TD>

</TR></TBODY></TABLE></TD></TR>

  

  

  

  

<TR>

<TD class=template-footer>

<TABLE cellSpacing=0 cellPadding=5 width="100%" align=left summary="" border=0>

<TBODY>

<TR>

<TD><IMG height=3 alt="" src="http://www.lse.ac.uk/images/v3/itservices/spacer.gif" width=4></TD>

<TD><A name=footer></A>

<P class=template-footertext><A href="http://www.lse.ac.uk/informationAbout/LSEWebsite/">About this site</A> | 

<A href="http://www.lse.ac.uk/feedback?type=about">About this page</A> | 

<A href="http://www.lse.ac.uk/feedback?type=comment">Comment on this page</A> </P>
 

<P class=template-footertext>Copyright © LSE. Use of this website is  subject to, and implies acceptance of, its (including 

<A href="http://www.lse.ac.uk/resources/termsOfUse/Default.htm#3">Copyright and intellectual property</A>, 

<A href="http://www.lse.ac.uk/resources/termsOfUse/Default.htm#5">Privacy and data protection</A>, and 

<A href="http://www.lse.ac.uk/resources/termsOfUse/Default.htm#7">Accessibility</A>).</P>

<P class=template-footertext>LSE, Houghton Street, London WC2A 2AE,UK; Tel: +44 (0)20 7405 7686</P></TD>

          <TD><IMG height=3 alt="" src="http://www.lse.ac.uk/images/v3/itservices/spacer.gif" 

            width=4></TD></TR></TBODY></TABLE>

			

			</TD></TR>

			

			

			</TBODY></TABLE></BODY></HTML>

Open in new window

0
Comment
Question by:LSE_IT_Training
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
dosth earned 500 total points
ID: 22838665
hi

go to line no 182

change this case "pubDate"  to case "pubdate", you will get the date and time.

thanks
Dosth

0
 

Author Comment

by:LSE_IT_Training
ID: 22839295
Wow, so simple. Many thanks!

Now that you've pointed it out, I think I understand why. Is it because the code uses this line:
Select case lcase(child.nodeName)?
0
 
LVL 15

Expert Comment

by:dosth
ID: 22839872
yes, your are correct that line make the value to lower case

thanks
Dosth
0
 

Author Closing Comment

by:LSE_IT_Training
ID: 31511107
Thanks very much for your help - it was driving me round the bend trying to figure out what was going on.
0
 
LVL 15

Expert Comment

by:dosth
ID: 22840065
glad to help, yes some time thing make us crazy :)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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)

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now