RSS Feed
Looking at the RSS home-news format on the example.com site it seems to be pulling certain things from the title and omitting others, how is this done?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="rss/channel">
<xsl:apply-templates select="item"/>
</xsl:template>
<xsl:template match="item">
<xsl:if test="position() < 9">
<p>
<a class="highlighted" href="{link}"><xsl:value-of select="substring(pubDate,6,11)"/></a><br/>
<xsl:value-of select="title"/>
</p>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
We have a php calendar that we can pull an RSS from and have been considering trying pull the RSS onto our homepage so that it is automatically updated instead of our PR department having to do what they currently do.
Here is a link to the RSS that we are wanting to use. http://www.jsu.edu/calendars/rss/rss2.0.php?cal=&cpath=&rss...
Comments are currently closed for this discussion. You can start a new one.
2 Posted by Eric L. Epps on 02 Aug, 2012 09:27 PM
I'm not sure I understand what you're trying to do, but here's a couple possibilities:
If you're trying to pull just "Tuscaloosa Area Alumni Dinner" from
<title>Thu Aug 2 2012: Tuscaloosa Area Alumni Dinner</title>, you could use<xsl:value-of select="substring-after(title,': ')" />If you're trying to find all RSS items which contain the word "Tuscaloosa" in the
<title>, you could use<xsl:apply-templates select="item[contains(title,'Tuscaloosa')]"/>3 Posted by glewis on 03 Aug, 2012 01:20 PM
Thanks - I thought there's be a way to do that. I tried it though and it didn't display anything.
Sent from my iPhone
Support Staff 4 Posted by Ryan Griffith on 03 Aug, 2012 01:55 PM
Hi glewis,
Just a few questions to see if we can narrow things down a bit:
Please let me know if you have any questions.
Thanks.
5 Posted by glewis on 03 Aug, 2012 03:00 PM
Well looking at the XML I saw my problem and fixed it lol - thanks!
Graham Lewis
Webmaster
Jacksonville State University
256.782.5331
www.jsu.edu
Support Staff 6 Posted by Ryan Griffith on 03 Aug, 2012 03:10 PM
Glad to hear you were able to get things working!
Im going to go ahead and close this discuss, but feel free to reply or comment to re-open this discussion if you have any additional questions.
Thanks.
Ryan Griffith closed this discussion on 03 Aug, 2012 03:10 PM.
glewis re-opened this discussion on 03 Aug, 2012 03:17 PM
7 Posted by glewis on 03 Aug, 2012 03:17 PM
Sounds good!
Graham Lewis
Webmaster
Jacksonville State University
256.782.5331
www.jsu.edu
Ryan Griffith closed this discussion on 03 Aug, 2012 03:25 PM.
glewis re-opened this discussion on 03 Aug, 2012 06:31 PM
8 Posted by glewis on 03 Aug, 2012 06:31 PM
Is there somewhere online I can find more examples of things I can use in the format to work with the RSS?
Graham Lewis
Webmaster
Jacksonville State University
256.782.5331
www.jsu.edu
Support Staff 9 Posted by Ryan Griffith on 03 Aug, 2012 07:11 PM
Apologies, but just to clarify, are you looking for examples of Formats that work with an RSS feed?
If so, I'm not seeing any off-hand, but perhaps others may be able to provide some input. The most typical usage I have seen is something similar to what you are doing, where the Format generates some sort of list with links to the article(s).
10 Posted by glewis on 03 Aug, 2012 07:13 PM
I was just trying to find different functions like the select =" substring-after(title,'- ')
Graham Lewis
Webmaster
Jacksonville State University
256.782.5331
www.jsu.edu
Support Staff 11 Posted by Ryan Griffith on 03 Aug, 2012 08:15 PM
Ah, I see.
I like to use the xPath Reference on the MSDN Library site because it refers to (I believe) XSLT 1.0, which is what Cascade uses. W3Schools also has a nice xPath Reference, but may include some functions/methods that are in XSLT 2.0.
12 Posted by glewis on 03 Aug, 2012 08:20 PM
Awesome - thanks!
Quick question - I am using <xsl:value-of select="substring-after(title,'- ')"/> but for certain items that don't have "- " it is removing them, is there a way to make it an if?
Graham Lewis
Webmaster
Jacksonville State University
256.782.5331
www.jsu.edu
Support Staff 13 Posted by Ryan Griffith on 03 Aug, 2012 08:35 PM
You could do something like:
The problem here; however, is that you could end up matching a valid title that contains a - in it, which could yield undesired results. For example, if you had a title Thu Aug 2 2012: Tuscaloosa Area Alumni Dinner - And Some More Text, you would end up with And Some More Text.
14 Posted by glewis on 03 Aug, 2012 08:45 PM
Thanks! You're awesome haha - if we choose do something like this, we will just have to make sure we format everything the same.
Graham Lewis
Webmaster
Jacksonville State University
256.782.5331
www.jsu.edu
Support Staff 15 Posted by Ryan Griffith on 03 Aug, 2012 09:00 PM
Yup, you got it. Or, perhaps remove the dates from the title since you already have the date using
pubDate?I'm going to go ahead and close this discussion, but feel free to reply or comment to re-open this discussion if you have any additional questions.
Thanks.
Ryan Griffith closed this discussion on 03 Aug, 2012 09:00 PM.