String Functions

XmlEncode
This is a simple function used to encode text and attribute values before adding them to your XML documents. This code can always be extended to handle maore special characters

public static String XmlEncode(String text){

    int[] chars = {38, 60, 62, 34, 61, 39};
    for(int i=0;i<chars.length-1;i++){
        text = text.replaceAll(String.valueOf((char)chars[i]),
            "&#"+chars[i]+";");
    }
    return text;
}