Fix escaping of XML chars in the MI output.

Credits go to Razvan.

(cherry picked from commit ae84ff06bcb886f6b169f0fa13fd928f9cb11c4e)