`
zhijin
  • 浏览: 75978 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

解决Dom4j中"The Node already has an existing parent"问题

 
阅读更多

 

 

常常需要在两个Document中互相复制Element,可是Dom4j中使用Element.add(Elemnet)方法就会出现出题的错误:

 

"The Node already has an existing parent"

 

 

查看AbstractElement.java的源码,得到解决办法:调用Element的clone()方法。

 

 

Element allAdd = (Element)add.clone();

xaldoc.getRootElement().add(allAdd);

分享到:
评论

相关推荐

    dom4jdemo例子

    DOM4J是一个非常灵活的Java XML API,它提供了全面的XML解决方案,包括XML解析、文档创建、修改以及XPath查询等功能。它不仅支持SAX和DOM这两种主流的XML处理模型,还引入了更为简洁的事件驱动模型。DOM4J的设计目标...

    510(k)-for-a-Change-to-an-Existing-Device.pdf

    a Change to an Existing Device Guidance for Industry and Food and Drug Administration Staff Document issued on October 25, 2017. The draft of this document was issued on August 8, 2016. This ...

    Deciding-When-to-Submit-a-510(k)-for-a-Software-Change-to-an-Existing-Device.pdf

    510(k) for a Software Change to an Existing Device ______________________________________________________________________________ Guidance for Industry and Food and Drug Administration Staff ...

    ORA-65122_ Pluggable database GUID conflicts with the GUID

    ORA-65122_ Pluggable database GUID conflicts with the GUID of an existing_ITPUB博客.mhtml

    Refactoring: Improving the Design of Existing Code 第二版

    This eagerly awaited new edition has been fully updated to reflect crucial changes in the programming landscape.Refactoring, Second Edition,features an updated catalog of refactorings and includes ...

    expect4j.jar 1.0

    Expect4j is an attempt to rewrite Expect in Java and provide bindings to the TclJava interpreter. The goal is to be able to port existing Tcl code bases that use Expect directly to Java without ...

    Refactoring Improving The Design Of Existing Code

    Refactoring Improving The Design Of Existing Code

    Refactoring Improving the Designof Existing Code(中英文版)

    《Refactoring: Improving the Design of Existing Code》是软件开发领域的一本经典著作,由Martin Fowler著述。这本书深入探讨了重构这一关键的软件工程实践,对于Java开发者来说尤其具有指导意义。重构是指在不...

    Node.js Design Patterns Second Edition[July 2016]

    You will gain an understanding of the basic building blocks and principles of writing large and well-organized Node.js applications and you will be able to apply these principles to novel problems ...

    Learning.Node.js.for..NET.Developers.epub

    This short guide will help you develop applications using JavaScript and Node.js, leverage your existing programming skills from .NET or Java, and make the most of these other platforms through ...

    Refactoring: Improving the Design of Existing Code

    通过实例和经验分享,作者们展示了如何在代码库中发现和解决设计问题,提升软件的长期质量和可持续性。同时,他们强调重构不仅仅是技术操作,更是一种思维方式,需要开发者具备对代码结构和设计模式的深入理解。 ...

    refactoring-improving the design of existing code.pdf

    1. **识别代码坏味道**:书中列举了多种常见的代码坏味道,如“长方法”、“重复代码”、“开关病例”等,并提供了识别这些问题的线索。 2. **重构模式**:Martin Fowler 提供了一系列的重构模式,每个模式都是一个...

    Rename an Existing Visual Studio project

    标题提到的"Rename an Existing Visual Studio project"是一个关于如何更改已创建的VS项目名称的主题。这个过程涉及到对项目文件、解决方案文件以及引用等多方面的修改,以确保重命名后的项目能够正常运行。 首先,...

    Refactoring Improving the Design of Existing Code.pdf

    重构涉及多种技巧和模式,它们可以帮助开发者识别并解决代码中的问题区域。书中列举了超过70种重构技巧,每一种技巧都包含一个简洁的名字、动机以及使用Java语言和UML表示法的例子。 - **技巧示例**: - **提取...

    Refactoring(Improving the Design of Existing Code)

    识别和解决代码异味是重构过程中的重要环节。作者通过大量实际案例,指导读者如何识别不良代码的模式,并通过一系列的重构手法进行改善。 重构的目录中包含了大量的重构手法,每一种手法都用“之前”和“之后”的...

    Refactoring Improving The Design of Existing Code

    Refactoring Improving The Design of Existing Code 重构已有代码

    下载覆盖已经存在的文件。「Downloads Overwrite Already Existing Files」-crx插件

    请参阅此处的源代码:https://github.com/zach-adams/downloads-overwrite-already-existing-files我不对丢失的数据负责。这不会在覆盖之前比较文件的内容,而只是比较文件名。 支持语言:English (United States)

    docx4j-3.3.6

    docx4j is an open source (Apache v2) library for creating, editing, and saving OpenXML "packages", including docx, pptx, and xslx. It uses JAXB to create the Java representation. Open existing docx/...

Global site tag (gtag.js) - Google Analytics