Fixed it so that if an object is NULL its value is written as an empty string to the XML instead of the script crashing.
Merge pull request #2 from joedyndale/HandleNULLObjects

Good catch.