Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    public static String escapeElementContent(String xmlContent) {
        return escapeElementContent(xmlContent, true);
    }

    public static String escapeElementContent(String xmlContent, boolean escapeEntities) {
        if (xmlContent == null)
            return "";
        String ret = xmlContent;
        if (escapeEntities)
            ret = ret.replace("&", "&");
        return ret.replace("<", "&lt;"); // There's no need to escape '>'.
    }
}