Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;

public class Main {

    public static String getXmlNodeValue(Document doc, String nodePath) throws Exception {
        XPath xpath = XPathFactory.newInstance().newXPath();
        String nodeValue = (String) xpath.evaluate(nodePath, doc, XPathConstants.STRING);
        return nodeValue;
    }
}