Implement XML/JSON API

This is additional work on #1698.

It aims to fix issues and replace some stuff (I'm really not sure about using Alice, as it proven many time to be hardly limited).
commented on purpose?