Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/maxim/wpxml_parser

Convenient WordPress XML dump parser.
https://github.com/maxim/wpxml_parser

Last synced: 4 days ago
JSON representation

Convenient WordPress XML dump parser.

Awesome Lists containing this project

README

        

wpxml_parser
============

WordPress (version 3.x and I think there's a plugin for 2.x) can export xml with all your blog posts, comments, etc. This tool can parse the xml file and give you a convenient access to all your posts, comments, categories, etc in a ruby script that _you have to write_.

The cool thing is — you don't even need to have access to your own WordPress database, all you need is to download the xml file from your admin panel.

### Install

gem install wpxml_parser

### Usage

require 'wpxml_parser'
include WpxmlParser

# Blog
blog = Blog.new('dump_of_your_blog.xml')
blog.posts.size # => 51
post = blog.posts.first # =>

# Post
post.title # => "Title of your post"
post.categories # => ["ruby", "rails"]
post.date # =>

# Conveniences
# You can quickly find a post or a comment by post_id or comment_id respectively
blog.find_post(27) # =>
post.find_comment(32) # =>

# For more info and more accessible properties check out the source code, it's pretty straightforward.

### A note on posts

Currently only published posts are included. Drafts, private, etc are skipped. This was done on purpose, since I didn't really use those wordpress features.

### A note on comments

Currently only approved comments are included. This was done on purpose, since I didn't need spam.