Html.fromHtml() removes carriage-returns “&#xD”, “\n”

邮差的信 提交于 2019-12-14 03:52:58

问题


As a response I am getting a string which is windows .ini file each pair has &#xD in the end this is the carriage-return in Canonical XML. After

String ini = Html.fromHtml(response).toString();

ini gets string with no line breaks instead of them white-spaces. How to keep line-breaks on their places?

Response comes as

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;Profile&gt;[General]&#xD;AutoRecoveryConversion=1&#xD;UpdateExistingBootScreen=0&#xD;EnableTraditionalBL=1....

and I have to deal with it as is, no change will be provided from server.


回答1:


If &amp;#xD; replaced in response string with <br/> output string contains proper line breaks.



来源:https://stackoverflow.com/questions/9121799/html-fromhtml-removes-carriage-returns-xd-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!