Reputation: 9
Unable to unescape consecutive escape char like <errors>. Below is the sample code:
String error = "&lt;errors&gt;";
String out = org.apache.commons.lang3.StringEscapeUtils.unescapeXml(error);
System.out.println(out);
Current Output: <errors>
Expected output: <errors>
This code ran on JDK 11.0.16 version and commons-lang3-3.4.jar version.
Upvotes: 0
Views: 126
Reputation: 83983
You need to unescape the String as many times as the input String has been escaped.
var input = "&lt;errors&gt;";
var output = StringEscapeUtils.unescapeXml(input);
output = StringEscapeUtils.unescapeXml(output);
System.out.println(output);
Upvotes: 0