Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {
    public static String lookupNamespaceURI(Node root, String specifiedPrefix) {
        if (root == null) {
            return null;
        }
        if (root.hasAttributes()) {
            NamedNodeMap nnm = root.getAttributes();
            for (int i = 0; i < nnm.getLength(); i++) {
                Node n = nnm.item(i);
                if (("xmlns".equals(n.getPrefix()) && specifiedPrefix.equals(n.getNodeName()))
                        || ("xmlns:" + specifiedPrefix).equals(n.getNodeName())) {
                    return n.getNodeValue();
                }
            }
        }
        return lookupNamespaceURI(root.getParentNode(), specifiedPrefix);
    }
}