android xml 解析汉字只出来一个字的问题

DocumentBuilderFactory factory = DocumentBuilderFactory

.newInstance();

// 实例化DocumentBuilder

factory.setCoalescing(true); //这个防止汉字被解码成1个汉字

DocumentBuilder builder = factory.newDocumentBuilder();

 

当没有使用factory.setCoalescing(true); 这个句子的时候,只能

解析出1个汉字。

根据官方资料显示,是xml标准规定的,当字符为非ASCII字符的时候

默认会解析成多个元素。

Coalescing的意思是合并,也就是将多个元素合并到一起。

所以能够得到正确的结果。

原文地址:https://www.cnblogs.com/stevenlaz/p/3256385.html