I get the input xml in the form of string. I do some transformations by converting it to document.
I need to convert this document back to string and send it to external system.
When I use pub.xml.documentToXMLString to convert document to xml, xml that got produced is having indentation.
I want it to be plain string.
Eg: Output of documentToXMLString is
123
I need
123
Team,
I have a hard deadline. I need to produce string with no new lines or extra spaces that get produced because of xml formating, from Document:
I need:
123
Not:
123
Is there any way?
Hello
You can try using pub.string:replace service the inputs of the service
InString-would be you xml i.e
123
SearchString - \n
replaceString - (leave empty)
UseRegex - true
This would produce the output as
123
Try it and let us know
thanks
Anil
A risky approach since it will replace newlines that are within the XML elements as well.
Insignificant whitespace (the new lines you’re trying to avoid) is allowed and is supposed to be handled properly by receiving parsers and applications. Why can’t the target system handle this valid XML? Solutions on your part to accommodate will possibly be fragile and add to maintenance efforts (e.g. why is this code building the XML itself?).
You could also try as
SearchString - >\n<
replaceString - ><
UseRegex - true
This ensures the new line character in data is not being touched…
HTH
Senthil