Java tutorial
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 CA. All rights reserved. * * This source file is licensed under the terms of the Eclipse Public License 1.0 * For the full text of the EPL please see https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ public class Main { public static String convertToXMLString(String instr) { //XML has a special set of characters that cannot be used in normal XML strings String ourstr = instr; ourstr = ourstr.replace("&", "&"); ourstr = ourstr.replace("<", "<"); ourstr = ourstr.replace(">", ">"); ourstr = ourstr.replace("\"", """); ourstr = ourstr.replace("'", "'"); return ourstr; } }