Code example for Node

Methods: getNodeType, getOwnerDocument

0
    protected String getXMLVersion(Node nodeArg) {
        Document doc = null;
         
        // Determine the XML Version of the document 
        if (nodeArg != null) {
            if (nodeArg.getNodeType() == Node.DOCUMENT_NODE) {
                // The Document node is the Node argument 
                doc = (Document)nodeArg;
            } else {  
                // The Document node is the Node argument's ownerDocument 
                doc = nodeArg.getOwnerDocument();
            } 
             
            // Determine the DOM Version. 
            if (doc != null && doc.getImplementation().hasFeature("Core","3.0")) {
                return doc.getXmlVersion();
            } 
        }  
        // The version will be treated as "1.0" which may result in 
        // an ill-formed document being serialized. 
        // If nodeArg does not have an ownerDocument, treat this as XML 1.0