Page 1 of 1

Handling XML special characters

Posted: Thu Mar 11, 2010 11:17 am
by pradkumar
Hi Everyone,

Iam using DB2 API stage to read the data from DB2 Mainframe and creating xml files using xml output stage. I have a requirement to handle XML special characters in our data. There are few special characters that need to be escaped in the XML files.

Character Escaped Value
& -- &
< -- &lt'
" -- "

The above are the standard XML character entities that will produce invalid XML if the characters are directly present in any data values. we have to make this as a standard and do it any xml output.But the chances of getting these characters in the data are rare.

I have searched the forum and trying to implement using the Convert function. Could any one let me know what would be the best approach and the soultion .

Thanks in Advance

Posted: Thu Mar 11, 2010 12:27 pm
by chulett
It's all automatic, you shouldn't have to do anything to get that to happen. Are you having an issue or just asking before you get started?

Posted: Thu Mar 11, 2010 1:39 pm
by pradkumar
Hi,

Thanks for your response.

But,I couldnt get what you meant "It will happen automatically".

Here is my scenario.

Character Escaped Value
& ---------- &
< ----------- <
> ----------- >
" ----------- "

The requirement is.. if the source data contains the character values mentioned above,it should be replaced with the escaped value.

Iam trying to replace these characters using the convert function. but it is taking only the first value as a replacement character but not the whole string (&).

eg: Convert(\&<>'"\,\&<>&aphos;"input column)

Is there any other ways to do this..?

Thanks.

Posted: Thu Mar 11, 2010 1:46 pm
by ArjunK
As chulett mentioned you don't have to do anything. The XML Output stage will automatically convert the XML reserved characters.

Posted: Thu Mar 11, 2010 2:39 pm
by pradkumar
Hi,

Thanks for the inputs.. It worked fine.

Iam marking this thread as resolved.