Unescape XML characters, and also replace our special token for preserving a carriage return followed by a line feed. - Java XML

Java examples for XML:XML String Escape

Description

Unescape XML characters, and also replace our special token for preserving a carriage return followed by a line feed.

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        String body = "java2s.com";
        System.out.println(unescapeBody(body));
    }//w w w  .  ja  v  a  2s.  c o  m

    /**
     * Unescape XML characters, and also replace our special token for preserving a carriage return followed by a line
     * feed.
     * 
     * @param body
     * @return
     */
    public static String unescapeBody(String body) {
        body = body.replace("&lt;", "<");
        body = body.replace("&gt;", ">");
        body = body.replace("CARRIAGERETURN\n", "\r\n");
        return body;
    }
}

Related Tutorials