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

Java: Getting the Document from a Node or Element

$
0
0

When we for instance wishes to add a new element we need to pass along the document. If we have a element or a node we can get the document that way. Simply call getOwnerDocument and we are good.

Element element = //code to get a element
Node node = //code to get a node
 
//document from Node
Document document = node.getOwnerDocument();
 
//document from a Element
Document document = element.getOwnerDocument();

Viewing all articles
Browse latest Browse all 10

Trending Articles