documentToXML String --- Need to remove white space

I have looked in this forum and have not found a real solution.

Currently, the documenToXMLString will produce the string below….

<?xml version="1.0" encoding="UTF-8"?> 1 TCCS.SAP_CCR

I want it to produce one long string as follows:

<?xml version="1.0" encoding="UTF-8"?> 1TCCS.SAP_CCR

if you have multi-levels in the XML…where the tags are indented…several levels…
using string replace is not a good option…
I have to replace the following with ><


when we use the documentToXMLString…
it basically adds a lot of white space and doubles the string size it generates.

The find string above does not show up correctly…

< with 1 space char
< with 2 space char
< with 3 space char

There is no easy way to output as wrapped XML and what document to xmlstring does is right of the format.

You have to create your own custom way of removing new lines/spaces etc…from the xmldata itself.


your xml is wrong.pls chk

Hi ,
If we want to get rid of new lines and spaces here is what I have tried and it worked.I guess there is no inbuilt machenism to remove extra lines and spaces .you just need to play with some services.


This is a bad idea. It will undoubtedly produce incorrect results in various circumstances.

hmm… I agree…

Try using pub.string:replace with regex set to ‘true’. Search string pattern is >[\n\t\s]*< and replace it with ><


Since your concern was for the size of the XML string, and thus presumably about the memory consumed by the string, you will want to consider that any manipulation of the XML string will result in at least double the memory usage.

In the past I’ve implemented a way to control the documentToXMLString formatting but alas I know longer have the information. That would be the way to go if you really want to change the format.

But I would advise this–leave it as is. There is likely very little benefit to gain in removing the whitespace between end/begin element tags. Unless the XML you’re generating is huge (say 500MB+) then you’re probably better off just accepting the existing format.