Importing BlogML into WordPress from Subtext

I used the BlogML importer plugin from http://dillieodigital.net/2010/07/03/blogml-importer to import my BlogML from Subtext. However the output from Subtext included Base64 encoded content so I wrote a little C# application to convert the Base64 decode the content before importing it.

The source code is below, the usual caveats about if it blows up your computer don’t blame me etc. apply.


using System;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace UnBase64BlogML
{
    class Program
    {
        static void Main(string[] args)
        {
            XDocument doc = XDocument.Load(@"blogml-b64.xml");
            XNamespace blogML = "http://www.blogml.com/2006/09/BlogML";

            var query = doc.Descendants(blogML + "content")
                .Where(node => (string) node.Attribute("type") == "base64");
            foreach(var item in query)
            {
                string content = Encoding.UTF8.GetString(Convert.FromBase64String(item.Value));

                item.SetValue(content);
            }

            doc.Save(@"blogml.xml");

            Console.WriteLine("Press a key to continue");
            Console.ReadKey(true);
        }
    }
}

4 thoughts on “Importing BlogML into WordPress from Subtext

  1. Thank you, this was a nice thing to find (saving me sometime). I am not quite sure why it was in base64 format and also why the importer that I used was able to read in base64.
    Thanks for the post.

    • It surprised me too, I thought it was because I included attachments in my export at first but a second export without them still gave me Base64 blog posts, and easy fix though.

  2. Greetings Rob, thanks for the pingback, though I’m a little late to the game here. 8^D I received a comment from somebody today that ran into the same issue, so it sounds like I might have to work that base64 conversion into the plugin for a future release. This gives me a perfect springboard for it, though I’ll have to do it in PHP naturally. 8^D

    Thanks again!
    [:: Sean ::]

  3. Pingback: Subtext to WordPress on Windows Azure Web Sites migration » Κ# on Cloud

Comments are closed.