⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e525. copying a subtree of nodes in a dom document.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
// Obtain an element; the following method is implemented in
    // e510 The Quintessential Program to Create a DOM Document from an XML File
    Document doc = parseXmlFile("infilename.xml", false);
    NodeList list = doc.getElementsByTagName("entry");
    Element element = (Element)list.item(0);
    
    // Make a copy of the element, including any child nodes
    Element dup = (Element)element.cloneNode(true);
    
    // Insert the copy immediately after the cloned element
    element.getParentNode().insertBefore(dup, element.getNextSibling());

This is the sample input for the example: 
    <root>
        <entry attr="value">
            a<i>b</i>c
        </entry>
    </root>

This is the resulting XML: 
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
        <entry attr="value">
            a<i>b</i>c
        </entry><entry attr="value">
            a<i>b</i>c
        </entry>
    </root>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -