Here you can find the source of XMLEncode(final String value)
Parameter | Description |
---|---|
value | a parameter |
public static String XMLEncode(final String value)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w ww . j a v a 2 s . co m*/ * encodes a value for safe use in XML * * @param value * @return * */ public static String XMLEncode(final String value) { String newValue = value.toString(); final String[] reps = new String[] { "&", "&", "<", "<", ">", ">", "\"", """, "'", "'" }; for (int i = 0; i < reps.length; i += 2) newValue = newValue.replace(reps[i], reps[i + 1]); return newValue; } }