syndicate fragments of RSS feed?

Discussion in 'HTML' started by Jared Zimmerman, Sep 1, 2006.

  1. 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?
     
    Jared Zimmerman, Sep 1, 2006
    #1
    1. Advertising

  2. Jared  Zimmerman

    Andy Dingley Guest

    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, Sep 1, 2006
    #2
    1. Advertising

  3. 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.
     
    Jared Zimmerman, Sep 2, 2006
    #3
  4. Jared  Zimmerman

    Andy Dingley Guest

    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, Sep 3, 2006
    #4
  5. 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).
     
    Jared Zimmerman, Sep 4, 2006
    #5
  6. Jared  Zimmerman

    Andy Dingley Guest

    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: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>
     
    Andy Dingley, Sep 4, 2006
    #6
  7. 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: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>
     
    Jared Zimmerman, Sep 8, 2006
    #7
  8. Jared  Zimmerman

    Andy Dingley Guest

    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.
     
    Andy Dingley, Sep 8, 2006
    #8
  9. 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.
     
    Jared Zimmerman, Sep 9, 2006
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger Varley

    Extracting XML fragments

    Roger Varley, Sep 2, 2003, in forum: Java
    Replies:
    3
    Views:
    751
    Toddy Marx
    Sep 4, 2003
  2. Replies:
    5
    Views:
    776
    SpaceGirl
    Feb 25, 2005
  3. Motta
    Replies:
    1
    Views:
    539
    Andy Dingley
    Jun 9, 2004
  4. Scott Gordo
    Replies:
    5
    Views:
    715
  5. Jonathan Groll
    Replies:
    1
    Views:
    282
    Kouhei Sutou
    Jun 27, 2009
Loading...

Share This Page