private String processSpecialCharacters(String s){
  if (s == null) {
    return null;
  }
  char[] charStr=s.toCharArray();
  String specialStr="";
  for (int i=0; i < charStr.length; i++) {
    if (charStr[i] == '&') {
      specialStr=specialStr.concat("&amp;");
    }
 else     if (charStr[i] == '<') {
      specialStr=specialStr.concat("&lt;");
    }
 else     if (charStr[i] == '>') {
      specialStr=specialStr.concat("&gt;");
    }
 else     if (charStr[i] == '\'') {
      specialStr=specialStr.concat("&apos;");
    }
 else     if (charStr[i] == '\"') {
      specialStr=specialStr.concat("&quot;");
    }
 else {
      specialStr=specialStr.concat(String.valueOf(charStr[i]));
    }
  }
  s=specialStr;
  return s;
}

private String processSpecialCharacters ( String s ) { if ( s == null ) { return null ; } char [ ] charStr = s . toCharArray ( ) ; String specialStr = "" ; for ( int i = 0 ; i < charStr . length ; i ++ ) { if ( charStr [ i ] == '&' ) { specialStr = specialStr . concat ( "&amp;" ) ; } else if ( charStr [ i ] == '<' ) { specialStr = specialStr . concat ( "&lt;" ) ; } else if ( charStr [ i ] == '>' ) { specialStr = specialStr . concat ( "&gt;" ) ; } else if ( charStr [ i ] == '\'' ) { specialStr = specialStr . concat ( "&apos;" ) ; } else if ( charStr [ i ] == '\"' ) { specialStr = specialStr . concat ( "&quot;" ) ; } else { specialStr = specialStr . concat ( String . valueOf ( charStr [ i ] ) ) ; } } s = specialStr ; return s ; }
this function has been added for the processing of special characters lik < , > , ' , " and & in the data to be serialized . these have to be taken of specifically or else there will be parsing error while trying to read the contents of the xml file .
