Here you can find the source of xmlEncode(String str)
Parameter | Description |
---|---|
str | the string to encode |
public static String xmlEncode(String str)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w w w . ja v a 2s .c o m*/ * Replaces &, <, >, " in a string with their respective XML representation * * @param str * the string to encode * @return a "save" encoded xml string (i.E. for usage in xml attributes) */ public static String xmlEncode(String str) { if (str == null) return null; str = str.replace("&", "&"); str = str.replace("<", "<"); str = str.replace(">", ">"); str = str.replace("\"", """); return str; } }