Adding script to escape XML entities correctly