code: public static StringBuilder escapeXML(char[] chars, int start, int count, StringBuilder destination) {
          // double quote -- quot
          // ampersand -- amp
          // less than -- lt
          // greater than -- gt
          // apostrophe -- apos
          for (int i = 0; i < count; i++) {
              char codePoint = chars[start + i];
              if (codePoint == '<') {
                  destination.append(LT);
              } else if (codePoint == '>') {
                  destination.append(GT);
              } else if (codePoint == '\"') {
                  destination.append(QUOT);
              } else if (codePoint == '&') {
                  destination.append(AMP);
              } else if (codePoint == '\'') {
                  destination.append(APOS);
              } else {
                  destination.append(codePoint);
              }
          }
          return destination;
      }
docs: Escapes a subset of a char sequence so that it is valid XML. Escaped or
  unchanged characters are added to destination.
  
  @param chars
  chars to check
  @param start
  start index (inclusive)
  @param count
  number of characters
  @param destination
  destination for escaped chars
  @return The modified destination.