syndicate fragments of RSS feed?

  • Thread starter Jared Zimmerman
  • Start date
J

Jared Zimmerman

i would like to syndicate part of the RSS feed here ( dodgeball check
ins ) http://www.dodgeball.com/history.rss?uid=50538&scod=9096800134 to
my status page here http://mrdrjr.com/ but the problem is the structure
of the feed is like this..

Jared Z. @ Latin American ClubFri, 01 Sep @ 03:36
Jared Z. @ Latin American Club
3286 22nd St
San Francisco, CA 94110


i want to only pull the location and city and nothing else so that why
i inline to my status page it can be

Jared is at X in Y. where X is the venue and Y is the City. does
anyone have any idea how i'd do this?
 
A

Andy Dingley

Jared said:
i would like to syndicate part of the RSS feed

Time to write some code - pick your favourite server-side scripting
language (from PHP and upwards).

As to parsing the RSS and extracting the piece you want, then XSLT
could do this fairly easily, with a couple of cautions:

* XSLT only works with well-formed XML, and RSS frequently isn't
well-formed XML. The example you quote isn't valid RSS, but it is close
enough to be processed with XSLT - at least today!

* XSLT is good at extracting the content of <description> with XPath,
but it's not ideal for extracting text such as your address. It's easy
enough in this case (use lots of calls to the substring-after()
functions) as it's only a simple case - but it will be messy.

XSLT would also make it easy to integrate the extracted results in with
the rest of your HTML page.
 
A

Andy Dingley

Jared said:
awsome now all i have to do is learn php and XSLT.....

You aren't going to get far without learning _something_, these are
just the easiest options.

PHP RSS -> XSLT -> HTML examples must be ten a penny if you search for
them. I'm sure you can find something ready-done. Enough PHP knowledge
to make use of this will take you a small amount of effort, but it's
probably worth it to pick up some useful knowledge for the future.

The XSLT is probably harder to learn, but much easier if you already
know it. Post a help request in comp.text.xml if you need - they're
pretty helpful over there (I'd probably write you one myself if I had
a few spare minutes).
 
J

Jared Zimmerman

Thanks, i don't mind learning, i was just hoping that it was a little
more simple, oh well
 
A

Andy Dingley

Jared said:
Thanks, i don't mind learning, i was just hoping that it was a little
more simple, oh well

Try this as a crude XSLT starter

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"


<xsl:eek:utput method="html"
omit-xml-declaration = "yes"
standalone = "yes"
doctype-public = "-//W3C//DTD HTML 4.01 Strict//EN"
doctype-system = "http://www.w3.org/TR/html4/strict.dtd"
cdata-section-elements = "script"
indent = "yes"
media-type = "text/html" />



<xsl:template name="embedded-br-to-text" >
<xsl:param name="input" select="/.." />

<xsl:variable name="cdr" select="substring-after ($input,
'&lt;br&gt;')" />

<xsl:choose>
<xsl:when test="$cdr" >
<xsl:value-of select="substring-before ($input, '&lt;br&gt;')"
/>
<xsl:text>
</xsl:text>
<xsl:call-template name="embedded-br-to-text" >
<xsl:with-param name="input" ><xsl:value-of select="$cdr"
/></xsl:with-param>
</xsl:call-template>
</xsl:when>

<xsl:eek:therwise><xsl:value-of select="$input" /></xsl:eek:therwise>
</xsl:choose>
</xsl:template>



<xsl:template name="one-item" >
<xsl:param name="rss-item" select="/.." />

<pre><xsl:value-of select="title" />
<xsl:text> </xsl:text>
<xsl:value-of select="pubDate" />
<xsl:text>
</xsl:text>
<xsl:call-template name="embedded-br-to-text" >
<xsl:with-param name="input" ><xsl:value-of
select="substring-after(substring-after(string(description),
'&lt;/a&gt;'), '&lt;/a&gt;')" /></xsl:with-param>
</xsl:call-template></pre>
</xsl:template>


<xsl:template match="/">
<html><title>Dodgeball</title><body>

<xsl:for-each select="//item" >
<xsl:sort select="pubDate" />

<xsl:if test="position() = 1" >
<xsl:call-template name="one-item" >
<xsl:with-param name="rss-item" select="." />
</xsl:call-template>
</xsl:if>
</xsl:for-each>

</body></html>
</xsl:template>



</xsl:stylesheet>
 
J

Jared Zimmerman

Thanks, i don't know the first thing about XML where does this go and
what do i need to change in it to put it in play?
 
A

Andy Dingley

Jared said:
Thanks, i don't know the first thing about XML where does this go

Web search for "RSS XSLT transformation in PHP" I'm sure you can find
downloadable RSS aggregator code in PHP. You'll need one that's XSLT
based, then just drop this XSLT stylesheet in instead.
what do i need to change in it to put it in play?

Probably nothing, just wrap it up and feed it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top