Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static String removeCDATA(String xml) {

        String CStart = "<![CDATA[";
        String CEnd = "]]>";
        String retval = "";

        int loc = xml.indexOf(CStart);
        // System.out.println("loc = "+loc);
        if (loc > -1) {
            String frontchop = remove(xml, CStart, loc);

            loc = frontchop.indexOf(CEnd);

            retval = remove(frontchop, CEnd, loc);

            xml = retval;
        }

        return xml;

    }

    private static String remove(String str, String toRemove, int location) {

        StringBuffer buffer = new StringBuffer(str);
        return buffer.replace(location, location + toRemove.length(), "").toString();

    }
}