code: public static String escapeElementContent(Object content)
      {
          if (content == null) {
              return null;
          }
          String str = String.valueOf(content);
          StringBuilder result = new StringBuilder((int) (str.length() * 1.1));
          int length = str.length();
          char c;
          for (int i = 0; i < length; ++i) {
              c = str.charAt(i);
              switch (c) {
                  case '&':
                      result.append(AMP);
                      break;
                  case '<':
                      result.append(LT);
                      break;
                  case '>':
                      result.append(GT);
                      break;
                  default:
                      result.append(c);
              }
          }
          return result.toString();
      }
docs: Escapes the XML special characters in a <code>String</code> using numerical XML entities, so that the resulting
  string can safely be used as an XML text node. Specifically, escapes &lt;, &gt;, and &amp;.
  
  @param content the text to escape, may be {@code null}
  @return a new escaped {@code String}, {@code null} if {@code null} input