Two things - firstly, you need to remove the
<pre>
from your xml or it will not process before you even start to "trim" it.
Secondly you cannot blindly remove all spaces: if you look at the string you generated:
<getInstallmentHistoryReplyxmlns:NS1="urn:esbbank.com/gbo/xml/schemas/v1_0/"><eAI_HEADER><serviceName>GET.FINANCE.DETAIL</serviceName>...
you can see that it is not valid XML: it needs a space between the
getInstallmentHistoryReply
tag and the
xmlns:
attribute or the whole looks like a longer attribute name with no proper tag preceding it.
I would suggest that you change your regex to only remove whitespace following a
>
tag ending marker