commons/core/src/main/java/org/ldp4j/xml/XMLUtils.java
public static String escapeXML(final CharSequence s) {
		final StringBuilder sb = new StringBuilder(s.length() * 2);
		final CodePointIterator iterator = new CodePointIterator(s);
		while (iterator.hasNext()) {
			final int codePoint = iterator.next();
			if (codePoint == '<') {
				sb.append(LT);
			} else if (codePoint == '>') {
				sb.append(GT);
			} else if (codePoint == '\"') {
				sb.append(QUOT);
			} else if (codePoint == '&') {
				sb.append(AMP);
			} else if (codePoint == '\'') {
				sb.append(APOS);
			} else {
				sb.appendCodePoint(codePoint);
			}
		}
		return sb.toString();
	}
public static String escapeXML(final CharSequence s) {
		final StringBuilder sb = new StringBuilder(s.length() * 2);
		final CodePointIterator iterator = new CodePointIterator(s);
		while (iterator.hasNext()) {
			final int codePoint = iterator.next();
			if (codePoint == '<') {
				sb.append(LT);
			} else if (codePoint == '>') {
				sb.append(GT);
			} else if (codePoint == '\"') {
				sb.append(QUOT);
			} else if (codePoint == '&') {
				sb.append(AMP);
			} else if (codePoint == '\'') {
				sb.append(APOS);
			} else {
				sb.appendCodePoint(codePoint);
			}
		}
		return sb.toString();
	}
Escapes a character sequence so that it is valid XML.

@param s
The character sequence.
@return The escaped version of the character sequence.