emadhu
asked on
replacing XML Special Characters
We have a program which reads the data from database and generates XML messages
Some data items have special characters like "A&P" , "G E". Since these characters are not allowed as XML element names. CAn you some point me to a code snippet or library which
takes a String and replaces all occurrences of "&", " ", " " with corresponding characters.
Example: The one on the left should be replaced with the one on the right
& --> ""
" " --> _
Some data items have special characters like "A&P" , "G E". Since these characters are not allowed as XML element names. CAn you some point me to a code snippet or library which
takes a String and replaces all occurrences of "&", " ", " " with corresponding characters.
Example: The one on the left should be replaced with the one on the right
& --> ""
" " --> _
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The class is part of Apache's commons lang project, you can download it here:http://commons.apache.org/lang/