<root>aaaa>bbbb <root/>中aaaa>bbbb的中的>不转变
对于Attribute 里面的特殊字符,我查了好久的原码发现人家里面是从
protected void writeEscapeAttributeEntities(String txt) throws IOException {
if (txt != null) {
String escapedText = escapeAttributeEntities(txt)
writer.write(escapedText)
}
}//(在XMLWriter类中第1174行)
里面有个 escapeAttributeEntities(txt)这个是专门用来转变Attribute 里面的特殊字符的,
所以要想解决这个问题,我是用了继承,写了一个
public class MyXMLWriter extends XMLWriter {
......
protected void writeEscapeAttributeEntities(String txt) throws IOException {
if (txt != null) {
//String escapedText = escapeAttributeEntities(txt)
writer.write(txt)
}
}
.......
}
直接注释了原码中的//StringescapedText=escapeAttributeEntities(txt)
就完美解决了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)