Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   HTML (http://www.velocityreviews.com/forums/f31-html.html)
-   -   syndicate fragments of RSS feed? (http://www.velocityreviews.com/forums/t368110-syndicate-fragments-of-rss-feed.html)

Jared Zimmerman 09-01-2006 06:25 PM

syndicate fragments of RSS feed?
 
i would like to syndicate part of the RSS feed here ( dodgeball check
ins ) http://www.dodgeball.com/history.rss...cod=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?


Andy Dingley 09-01-2006 07:05 PM

Re: syndicate fragments of RSS feed?
 

Jared Zimmerman wrote:

> 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.


Jared Zimmerman 09-01-2006 11:15 PM

Re: syndicate fragments of RSS feed?
 
awsome now all i have to do is learn php and XSLT.....


Andy Dingley wrote:
> Jared Zimmerman wrote:
>
> > 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.



Andy Dingley 09-03-2006 12:41 PM

Re: syndicate fragments of RSS feed?
 
Jared Zimmerman wrote:

> 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).


Jared Zimmerman 09-04-2006 07:17 AM

Re: syndicate fragments of RSS feed?
 
Thanks, i don't mind learning, i was just hoping that it was a little
more simple, oh well


Andy Dingley wrote:
> Jared Zimmerman wrote:
>
> > 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).



Andy Dingley 09-04-2006 11:47 AM

Re: syndicate fragments of RSS feed?
 

Jared Zimmerman wrote:

> 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:output 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:otherwise><xsl:value-of select="$input" /></xsl:otherwise>
</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>


Jared Zimmerman 09-08-2006 07:12 AM

Re: syndicate fragments of RSS feed?
 
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?


Andy Dingley wrote:
> Jared Zimmerman wrote:
>
> > 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:output 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:otherwise><xsl:value-of select="$input" /></xsl:otherwise>
> </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>



Andy Dingley 09-08-2006 08:42 AM

Re: syndicate fragments of RSS feed?
 

Jared Zimmerman wrote:

> 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.


Jared Zimmerman 09-09-2006 07:04 AM

Re: syndicate fragments of RSS feed?
 
Thanks ill let you know how it works when i get to check it out


Andy Dingley wrote:
> Jared Zimmerman wrote:
>
> > 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.




All times are GMT. The time now is 01:56 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.