Node node = element.getChildNodes().item(0); Document ownerDocument = node.getOwnerDocument();
Document doc = builder.parse(input); Node node = doc.getDocumentElement(); Document ownerDocument = node.getOwnerDocument();In this example, we parse an XML document using the DocumentBuilder class and get the owner document of its root element. This method is part of the org.w3c.dom.Node interface, which is included in the Java standard library.