Redirection symbols can be escaped by placing those within double quotes ".
"
Instead of saying
'<gateway><gateway_type>test</gateway_type></gateway>'
you need to say
"<gateway><gateway_type>test</gateway_type></gateway>"