Quantcast
Channel: Jontas » Java
Viewing all articles
Browse latest Browse all 10

Java: Adding a Element under an Element (or Converting a Element to a Node)

$
0
0

When using Document a Element can only be appended with a Node, but what if we have a Element ?

Easy, Element extends Node so just pass the Element along and all is well

import org.w3c.dom.Document;
import org.w3c.dom.Element;
 
Document doc;
Element newElement;
Element oldElement; //code to find that
newElement = doc.createElement("tag");
oldElement.appendChild(newElement);

Viewing all articles
Browse latest Browse all 10

Trending Articles