WordPress WXR Class

One of the most frustrating things to me in my years of working with WordPress and b5media has been migrating blogs into WordPress. Every blog platform does things differently and although WordPress has import support for a large number of blog platforms, it always seems like I get the job of migrating from platforms that don’t have any way of exporting posts to take to a different platform, such as WordPress.

I’ve done a number of these migrations now – Nucleus, Drupal, Serendipity and others. The latest was Expression Engine – needed to move Shai’s blog over to WordPress. This was the catalyst I needed to write a base class for the WordPress import/export format known as WXR, or WordPress eXtended RSS.

For casual users, this is not for you. For developers, this may be a life saver for you.

The class can be downloaded via SVN:

svn co http://svn.aaronbrazell.com/wpwxr/trunk wpwxr

Included in this repository is the base class.wxr.php class along with sample code to build your own apps from.

Reference: Complete WordPress WXR Base Class documentation is online.

Instantiation: This is a base class. Therefore, you should never extantiate it directly – only via another class via extending.


class myNewClass extends WXR_export {

	function myfunction()
	{
		echo "Hello World!";
	}
}

Debug mode: If you wish to use debug mode, you can set the $debug property of the class to true. The default is false. If debug mode is on, output will be sent to the screen as opposed the the WXR file.

Example:


$n = new myNewClass;
$n->debug = true;

Export Filename: By default, the name of the WXR file is date based (e.g wxr-2008-01-26.xml). You can change this by changing the $export_filename property.


$w = new myNewClass();
$w->export_filename = 'file-movabletype.xml';

I’d love to get patches if you want to contribute. You should send them to emmensetech [at] gmail [dot] com. In addition, if you use this and create extension classes, I’m more than happy to host them. I’ll be seeding the pot with the Expression Engine class I used this weekend.

Exporters Built

About Aaron
I am the Lead Editor of Technosailor.com, the Author of the WordPress Bible, a WordPress project core contributor, public speaker and an all around badass. If you're interested in having me speak at your event, contact me.

Comments

  1. Shai Coggins says:

    LOL. And part of that job is my bad – for choosing ‘uncooperative systems’ like Nucleus and Expression Engine. ;-)

  2. Aaron says:

    Glad to help, Shai

  3. Mike says:

    I can’t seem to connect to your SVN and 404 for the class documentation. Is this and the Expression Engine exporter still available? Could be a huge time saver. Thanks in advance!

  4. Aaron says:

    Mike-

    The SVN repository was irrevocably lost awhile ago… and all that was within perished.

Speak Your Mind

*