XML Parsing for special characters

Hi Experts,

We have a requirement for sending a xml which comes from sap as an idoc(message type remains same for 3 vendors) to 3 different vendors.

First two should receive the xml as iso-8859-1 encoding.

Third one should receive the xml as UTF-8 encoding.

When we receive the idoc, routing rules are matched then it comes to our main service in which we defined a service pub.sap.encode and given encoding as iso-8859-1and successfully sent the idoc converted xml to First two vendors in iso-8859-1 encoding.

For third vendor the same xml(iso-8859-1 ) has been encoded to UTF-8 in documentToXMLString and XMLStringToXMLnode (specified encoding as UTF-8) services.

The result xml is showing encoding as UTF-8, but it consists all the special characters.

Could anyone suggest us how to resolve this issue.



Did you set “encode” to true when you call documentToXMLString ?



Yes, we set “encode” to true when we call documentToXMLString

you need to create java service to do the encoding conversion.
check java.nio.charset.Charset, java.nio.charset.CharsetDecoder, java.nio.charset.CharsetEncoder.

by changing the encoding on the xml tag you won’t change the encoding of the content.

The encode parameter controls the conversion of characters that have special meaning in XML to character entities. e.g. the ‘&’ is “encoded” into ‘&’. The encode parameter of documentToXMLString has nothing to do with the character set encoding.