使用Dom4j在指定的节点上添加节点怎么做

使用Dom4j在指定的节点上添加节点怎么做,第1张

通过节点的style属性添加 1、定义一个节点 2、获取div节点 var domdiv = document.getElementById('tsdiv')//通过document.getElementById获取dom节点3、添加style div.style.display = 'none'//添加style属性,设置display样式为none

setEscapeText(false) 只是能改变 escapeElementEntities(String st) 中的参数,主要能改变文本里面如:

<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)

就完美解决了。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11871484.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存