Honor toJSON/toXML() for XML support

/to @ritch @bajtos 

The PR allows customization of JSON to XML conversion using toJSON()/toXML(). It also adds some test cases for XML media types.
Let's say `input` is an array of Model instances. Will this recursively call `toJSON` for each model in the array? Can you add an explicit test case to verify and document the correct/expected behaviour?