Skip to Content
0
Former Member
Jun 07, 2007 at 02:28 PM

Adapter module converting XML to text using sax parser.

58 Views

Hi

I have created a adapter module to convert xml message to text. I used sax parser for that purpose.

Module works fine. But module starts giving problems when we give some German characters in the xml message.

It replaces corresponding German characters with a question mark.

for eg. if the value of a text node is ABÜG, this is converted as AB?G.

The xml file is encoded with "UTF-8" and below is the code fragment to parse the xml message -

SAXParserFactory spf = SAXParserFactory.newInstance();

spf.setNamespaceAware(true);

spf.setValidating(true);

saxParser = spf.newSAXParser();

InputStream is = new ByteArrayInputStream(payload.getBytes());

InputSource iSource = new InputSource(is);

iSource.setEncoding("ISO-8859-1");

saxParser.parse(iSource, this);

if(null != is){

is.close();

}

Thanks in advance.