utils: refactor XML escaping

* Refactors the XML escaping to also take in to account < as &lt;.

Co-authored-by: Georgios Papoutsakis <georgios.papoutsakis@cern.ch>