Use more standard prototypical inheritance for toXml methods

After sleeping on it, it dawned on me that the implementation of the `toXml` methods could be done in a more prototypical fashion. It's more a style thing and doesn't really make much difference functionality wise, so feel free to disregard this pull request if you like.