A fix for some errors in escapeXML()
Fixed an issue in escapeXML() whereby if the supplied value is undefined, a JavaScript error was thrown.
I have implemented this fix in a generic fashion, i.e. it will now behave correctly for any non-string value that doesn't implement a toString() method (not just undefined values). If toString() is available, then this will be used to convert the value to a string prior to performing the necessary replacements, otherwise we catch the resulting JavaScript error and return an empty string.
This works around an IE8 issue, whereby node.node.className.baseVal is not defined, resulting in a 'class' attribute set to undefined. I have logged the underlying issue as issue #53, but this fix means that we should no longer generate a JavaScript error when this situation occurs.
I have also added a fix for the fact that ampersands weren't being escaped properly, which resulted in invalid markup in situations where an ampersand is present in an attribute property.
If you need me to submit these as separate pull requests, I can. However, as they touch the same code it would require rebasing whichever commit gets pulled last, so I thought it more sensible to include them jointly in the same PR.
Hopefully this second commit will fix issue #46.