Forum: Ruby on Rails can't get my rss to validate with feedtools

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Charlie B. (Guest)
on 2006-03-20 20:31
I know that I'm doing something wrong, but I can't figure out what.
I've looked at every wiki and tutorial I can find on feedtools but I
still can't get my rss feed working.  Here's my code.

feed = FeedTools::Feed.new

feed.entries << FeedTools::FeedItem.new

feed.entries[0].author.name = "Charlie B."
feed.entries[0].title = @post.title
feed.entries[0].link = "http://server:3000/pragmatic/"
feed.entries[0].content = @post.post

# Assumes this is inside a .rxml file
feed.entries[0].build_xml("rss", 2.0,xml)

Here's what the validator tells me.  Thanks for any input!

This feed does not validate.

    *

      line 1, column 0: Undefined root element: item [help]

          <item>

    *

      line 4, column 2: XML parsing error: <unknown>:4:2: unbound prefix
[help]

            <dc:creator>Charlie B.</dc:creator>
            ^

Source: http://server:3000/pragmatic/rss

   1. <item>
   2.  <title>er</title>
   3.  <link>http://server:3000/pragmatic/</link>
   4.  <dc:creator>Charlie B.</dc:creator>
   5.  <content:encoded>
   6.    <![CDATA[<p>gdf</p>]]>
   7.  </content:encoded>
   8.  <pubDate>Mon, 20 Mar 2006 18:52:17 -0000</pubDate>
   9.  <guid isPermaLink="true">http://server:3000/pragmatic/</guid>
  10. </item>
  11.

Home · About · News · Docs
Dave S. (Guest)
on 2006-03-21 05:37
(Received via mailing list)
On Monday 20 Mar 2006 18:31, charlie bowman wrote:
> I know that I'm doing something wrong, but I can't figure out what.
> I've looked at every wiki and tutorial I can find on feedtools but I
> still can't get my rss feed working.  Here's my code.

Surely you need to add the XML prolog and say what RSS version you're
using
and so on?  See:
http://searchenginewatch.com/sereport/article.php/2175271

For example, your output code needs to be something more like:

<?xml version="1.0" ?>
<rss version="2.0">
  <channel>
    <title>My funky RSS feed</title>
    <description>If it's happening, you'll find it here!</description>
    <link>http://www.mysite.com</link>
    <item>
      <title>er</title>
      <link>http://server:3000/pragmatic/</link>
      <dc:creator>Charlie B.</dc:creator>
      <content:encoded>
        <![CDATA[<p>gdf</p>]]>
      </content:encoded>
      <pubDate>Mon, 20 Mar 2006 18:52:17 -0000</pubDate>
      <guid isPermaLink="true">http://server:3000/pragmatic/</guid>
    </item>
  </channel>
</rss>


Hmm... actually, I hadn't found FeedTools yet (until right this second).
Anyway, from the tutorial at:

http://sporkmonger.com/articles/2005/08/11/tutorial/

... looks like you need to call something in your view like:

@feed.build_xml((@feed_type or "atom"), 0.0, xml)

Are you doing that?  From the source you posted, it basically looks like
you
aren't turning it into a proper XML document, which should hopefully
explain
why it won't validate, since you're only generating half of it.

Any help?

~Dave

--

Dave S.
Rent-A-Monkey Website Development
http://www.rentamonkey.com/

PGP Key: http://www.rentamonkey.com/pgpkey.asc
Charlie B. (Guest)
on 2006-03-21 15:40
(Received via mailing list)
Actually, I gave up on feedtools and decided just to write some xml. I
tried to follow sporkmongers tutorial for creating a feed but couldn't
get it to work.

On Tue, 2006-03-21 at 03:37 +0000, Dave S. wrote:

> <?xml version="1.0" ?>
>         <![CDATA[<p>gdf</p>]]>
>
> Any help?
>
> ~Dave
>

Charlie B.
Programmer
Castle Branch Inc.
Bob A. (Guest)
on 2006-07-10 23:40
(Received via mailing list)
> feed.entries[0].link = "http://server:3000/pragmatic/"
> feed.entries[0].content = @post.post
>
> # Assumes this is inside a .rxml file
> feed.entries[0].build_xml("rss", 2.0,xml)

Sorry for digging up this old post, but I only just saw it.  Mea culpa.

Simple fix:

You're building the XML for the feed item.  You need to build the XML
for the feed itself:

feed.build_xml("rss", 2.0, xml)

Cheers,
Bob A.
--
AIM: sporkmonger
Jabber: removed_email_address@domain.invalid
This topic is locked and can not be replied to.