Importing bad BlogML - better error messages

Aug 18, 2009 at 9:59 PM
Edited Aug 19, 2009 at 7:42 AM

I'm currently moving to Oxite from a home grown blogging engine I wrote years ago. I wrote my own BlogML exporter to speed things up.
The BlogML I produced had a lot of problems, which I've now figured out by stepping through the BlogMLSave action method.

I've a few suggestions that could help make the error detection and messages better.
Although hopefully most people won't have the BlogML problems I've had, because they won't be writing their own blogML.

1. Badly formed XML

If there is a problem with the XML an exception is thrown and it is caught by this bit of code, which I modified slightly to give a more helpful warning in my case.


catch (Exception ex)

    if (!string.IsNullOrEmpty(ex.Message))
         ModelState.AddModelError("ModelName", ex.InnerException.Message);
    return BlogML(areaInput);

I think it should be possible to use the information in the exception to give a very useful error message that shows a snippet of your XML where the problem is.

2. Missing <![CDATA[ --- ]]> tags in content

I missed off these tags and it caused the import to wrongly report it had been successful.
The missing CDATA tags caused blogMLPost.Content.Text to be empty in the imported XML.
This line checks for blank title and content and proceeds to the next post if either are blank:

if (string.IsNullOrEmpty(blogMLPost.Title) || string.IsNullOrEmpty(blogMLPost.Content.Text))
It should also keep track of how many posts haven't been imported and report this as an error.

Hope that's helpful. Loving Oxite and MVC. Keep up the good work.


Aug 19, 2009 at 6:37 PM

Good suggestions.  Thank you!  I will be working on import soon-ish and will take these suggestions into consideration when I get things fixed up.

Glad you like Oxite (and MVC) so far and do let us know if you have other questions or problems you find.  Thanks!

Aug 20, 2009 at 11:02 PM

Thanks Erik.

I've uploaded my very quick and dirty blogML converter to Code gallery incase anyone esle is trying to do what I've done. It's not fab code, but it does the trick. It won't work out of the box, but it should be a nice starting place for people wanting to get content out of a blogging engine they made themselves.

Aug 21, 2009 at 7:27 AM

Cool, thanks for sharing!  And glad you got it going.  Let us know if you have any other questions.