XML String Formating

I currently have an xml string output from the documentToXMLString service. The service places carriage return in the string, I assume for formatting the xml. Is there any way to have these carriage returns eliminated so that the xml is placed in the string element by element with no carriage returns or spaces?

cant you do a pub.string.replace.?

I do not know what character to replace, becuase I am not sure what webMethods uses as a carriage return. Any ideas?

Hi, BP234.

A good exercise for you will be to review the Built-In Services guide. That document should be your first point of reference for any questions that you have.

The Built-In Services Guide is extremely thorough – it describes in detail every out-the-box webMethods service and its inputs, outputs and cautionary notes.

I have been using the webMethods Platform for years and still refer to the Built-In Services guide regularly.

Good luck developing your new webMethods skill set!

As Dan replied, the most appropriate thing will be to refer the guide.
Even still I hope Dan wont be offended if I answer this question.

in the pub.string.replace, open up the search string, right click and select use larger editor and then point the cursor inside and hit enter.
then hit ok and just leave the replace string as blank.


Hi, BP234.

VR is right – manually enter a carriage return in the “Larger Editor”. This will work for Windows-to-Windows Integration or UNIX-to-UNIX integrations, but may cause cross-platform problems.

The manual carriage return will be interpreted by whichever platform the host server runs. So, if you replace a line feed with \n\r in Windows and then send that document to a UNIX server, you will get unexpected results. The reverse it true, too.

Keep that in mind when architecting your solution.

Also, you may also find that your projects require special characters such as \t or double-byte characters. There has been some discussion on this topic here at wMUsers.com. Use the Search the Forums link to do some research.

It worked, thanks for your help

There doesn’t look like a way to get documentToXMLString to not put in “\n” and pad with formating spaces.

It would be a good feature request, because this stuff does bloat the already bloated XML.

Note that trying to do the proposed replace will be rife with potential trouble. Simply replacing \n with nothing may corrupt real data held within the data elements. Whitespace outside of the data elements is insignificant, but whitespace within data elements is very significant. Trying to remove insignificant whitespace pretty much requires parsing the XML.

I posted this request long time ago but looks like THEY forgot …!!!
The SR# is 1-8119104. The request and response I got are below. Please remind THEM!!! Your point is VERY VALID.

Sent: Tuesday, November 20, 2001 4:18 PM
Subject: RE: B2B recordToDocument needs enhancement


I will log this as a feature request.


Girish R.


Sent: Tuesday, November 20, 2001 4:18 PM
To: webMethodsSupport
Subject: B2B recordToDocument needs enhancement

Dear support,

Working with B2B 4.0, I noticed that the built in service recordToDocument should be improved. There should be a true/false option if the generated XML should be formatted as one line (no spaces or line feeds) or formatted as nice view (lots of space characters and line feeds).

The ‘nice view’ format is good when viewing (or during development); however, it wastes lots of network space when trying to transmit to different box. The ‘nice view’ XML is about two times the size of the ‘one line’ XML.

While we’re at it, ask them to rename the method ‘recordToString’. ;o)

Will Kriski

It was renamed to pub.xml:documentToXMLString in 6.0, since “Records” were re-named “Documents”. The old service is still there, but deprecated and it will have a List ACL that keeps it from showing up in most users’ namespace browser in Developer.

Maybe the new name will grow on me…

How do you specify carriage return for the searchString value, does this function recognize ascii codes?

Please read the entire thread. The answer is already here.