<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: typo code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 07 Sep 2008 02:30:08 GMT</pubDate>
    <description>DZone Snippets: typo code</description>
    <item>
      <title>Typo export to WordPress WXR</title>
      <link>http://snippets.dzone.com/posts/show/3264</link>
      <description>If you want to move from Typo to Wordpress, you can use this to export the strange Wordpress RSS file format (comments and all).&lt;br /&gt;&lt;br /&gt;Just add this to the XmlController :&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  def wp&lt;br /&gt;    @articles = Article.find( :all, :include =&gt; [:categories, :tags, :user, :blog])&lt;br /&gt;  end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;And then add this file (app/views/xml/wp.rxml):&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;// insert code here..&lt;br /&gt;xml.instruct! :xml, :version=&gt;"1.0", :encoding=&gt;"UTF-8"&lt;br /&gt;&lt;br /&gt;xml.rss 'version' =&gt; "2.0", 'xmlns:content' =&gt; "http://purl.org/rss/1.0/modules/content/", 'xmlns:wfw' =&gt; "http://wellformedweb.org/CommentAPI/", 'xmlns:dc' =&gt; "http://purl.org/dc/elements/1.1/", 'xmlns:wp' =&gt; "http://wordpress.org/export/1.0/" do&lt;br /&gt;  xml.channel do&lt;br /&gt;    xml.title @feed_title&lt;br /&gt;    xml.link @link&lt;br /&gt;    xml.language "en-us"&lt;br /&gt;    xml.ttl "40"&lt;br /&gt;    xml.description this_blog.blog_subtitle&lt;br /&gt;&lt;br /&gt;    @articles.each do |a|&lt;br /&gt;        xml.item do&lt;br /&gt;          xml.title post_title(a)&lt;br /&gt;          xml.content(:encoded) { |x| x &lt;&lt; '&lt;![CDATA[' + a.full_html + ']]&gt;' }&lt;br /&gt;          xml.pubDate a.published_at.rfc2822&lt;br /&gt;          xml.guid "urn:uuid:#{a.guid}", "isPermaLink" =&gt; "false"&lt;br /&gt;          author = a.user.name rescue a.author&lt;br /&gt;          xml.author author&lt;br /&gt;          xml.dc :creator, author&lt;br /&gt;          for category in a.categories&lt;br /&gt;            xml.category category.name&lt;br /&gt;          end&lt;br /&gt;          for tag in a.tags&lt;br /&gt;            xml.category tag.display_name&lt;br /&gt;          end&lt;br /&gt;          xml.wp :post_id, a.id&lt;br /&gt;          xml.wp :post_date, a.published_at.strftime("%Y-%m-%d %H:%M:%S")&lt;br /&gt;          xml.wp :comment_status, 'closed'&lt;br /&gt;          xml.wp :ping_status, 'closed'&lt;br /&gt;          xml.wp :post_name, a.permalink&lt;br /&gt;          xml.wp :status, 'publish'&lt;br /&gt;          xml.wp :post_parent, '0'&lt;br /&gt;          xml.wp :post_type, 'post'&lt;br /&gt;          for comment in a.comments&lt;br /&gt;            xml.wp(:comment) do&lt;br /&gt;              xml.wp :comment_id, comment.id&lt;br /&gt;              xml.wp :comment_author, comment.author&lt;br /&gt;              xml.wp :comment_author_email, comment.email&lt;br /&gt;              xml.wp :comment_author_url, comment.url&lt;br /&gt;              xml.wp :comment_author_IP, comment.ip&lt;br /&gt;              xml.wp :comment_author_date, comment.published_at.strftime("%Y-%m-%d %H:%M:%S")&lt;br /&gt;              xml.wp(:comment_content) { |x| x &lt;&lt; comment.full_html }&lt;br /&gt;              xml.wp :comment_approved, '1'&lt;br /&gt;              xml.wp :comment_parent, '0'&lt;br /&gt;            end&lt;br /&gt;          end&lt;br /&gt;        end&lt;br /&gt;    end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Then hit your typo blog at http://myblog/xml/wp and save the file to import through the WordPress interface.</description>
      <pubDate>Tue, 09 Jan 2007 23:52:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3264</guid>
      <author>schacon (Scott Chacon)</author>
    </item>
  </channel>
</rss>
