解决Dom4j中"The Node already has an existing parent"问题 !
摘要:
常常需要在两个Document中互相复制Element,可是Dom4j中使用Element.add(Elemnet)方法就会出现出题的错误:而应用AppendContext()方法,只能将目标元素的内容复制过来,不能将整个元素复制通过看AbstractElement.java的源码得到解决办法是:调用Element的clone()方法。root.add((Element) company.clone());public Document createXMLDocument(){ Document doc = null; doc = DocumentHelper.createDocument() 阅读全文
posted @ 2011-12-06 16:09 Snowberg 阅读(2613) 评论(0) 推荐(0)
浙公网安备 33010602011771号