Java tutorial
//package com.java2s; public class Main { private static final String XML_LINEARIZATION_REGEX = "(>|>){1,1}(\\t)*(\\n|\\r)+(\\s)*(<|<){1,1}"; private static final String XML_LINEARIZATION_REPLACEMENT = "$1$5"; /** * * @param xml * @return linearized */ public static String linarizeXml(String xml) { return (xml != null) ? xml.trim().replaceAll(XML_LINEARIZATION_REGEX, XML_LINEARIZATION_REPLACEMENT) : null; } }