public static String escapeElementEntities(String xml) {
		StringBuilder buffer = new StringBuilder();
		for (int offset = 0; offset < xml.length();) {
			int codePoint = xml.codePointAt(offset);
			offset += Character.charCount(codePoint);

			if ((codePoint < ' ') && (codePoint != 0x09) && (codePoint != 0x0A) && (codePoint != 0x0D)) {
				continue;
			}
			if (codePoint >= 0x7F) {
				buffer.append("&#x");
				buffer.append(Integer.toString(codePoint, 16).toUpperCase());
				buffer.append(";");
				continue;
			}
			switch (codePoint) {
				case '<':
					buffer.append(LESS_THAN);
					break;
				case '>':
					buffer.append(GREATER_THAN);
					break;
				case '\'':
					buffer.append(APOSTROPHE);
					break;
				case '"':
					buffer.append(QUOTE);
					break;
				case '&':
					buffer.append(AMPERSAND);
					break;
				default:
					buffer.appendCodePoint(codePoint);
					break;
			}
		}
		return buffer.toString();
	}
Converts any special or reserved characters in the specified XML string
into the equivalent Unicode encoding.

@param xml the XML string
@return the encoded XML string
Ghidra/Framework/Generic/src/main/java/ghidra/util/xml/XmlUtilities.java