Java XML Node Value getNodeValue(Node node, String nodeKey)

Here you can find the source of getNodeValue(Node node, String nodeKey)

Description

get Node Value

License

Open Source License

Declaration

private static String getNodeValue(Node node, String nodeKey) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.w3c.dom.Node;

public class Main {
    private static Pattern attrExtractor = Pattern.compile("\"(.*)\"");

    private static String getNodeValue(Node node, String nodeKey) {
        Node opt_item = node.getAttributes().getNamedItem(nodeKey);
        if (opt_item != null) {
            Matcher nameMatcher = attrExtractor.matcher(opt_item.toString());
            if (nameMatcher.find()) {
                return nameMatcher.group(1);

            }//from   ww  w .j  a  va  2  s. com
        }
        return null;
    }
}

Related

  1. getNodeValue(Node node)
  2. getNodeValue(Node node)
  3. getNodeValue(Node node)
  4. getNodeValue(Node node, String name, boolean trim)
  5. getNodeValue(Node node, String name, String defaultVal, int index)
  6. getNodeValue(Node nodeXML)
  7. getNodeValue(org.w3c.dom.Node node)
  8. getNodeValue(org.w3c.dom.Node node)
  9. getNodeValueAsDate(Node node)