Java String Quote quoteForXML(String from)

Here you can find the source of quoteForXML(String from)

Description

quote For XML

License

Open Source License

Declaration

public static String quoteForXML(String from) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String quoteForXML(String from) {
        String to = from.replace("&", "&"); //$NON-NLS-1$ //$NON-NLS-2$
        to = to.replace("<", "&lt;"); //$NON-NLS-1$ //$NON-NLS-2$
        to = to.replace(">", "&gt;"); //$NON-NLS-1$ //$NON-NLS-2$
        to = to.replace("'", "&#39;"); //$NON-NLS-1$ //$NON-NLS-2$
        to = to.replace("\"", "&quot;"); //$NON-NLS-1$ //$NON-NLS-2$
        return to;
    }/*from   w  w  w. java2s  . c  o m*/
}

Related

  1. quoteForCommandString(String s)
  2. quoteForCsv(final String field)
  3. quoteForHTML(String toQuote)
  4. quoteForMdx(StringBuilder buf, String val)
  5. quoteForRegEx(String input)
  6. quoteHost(final String hostname)
  7. quoteHtml(final String s)
  8. quoteHtml(String s)
  9. quoteHTML(String string)