Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

public class Main {
    public static String selectString(String xpath, Object node) {
        try {
            return ((String) getXPath(xpath).evaluate(node, XPathConstants.STRING)).trim();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    private static XPathExpression getXPath(String xpath) throws XPathExpressionException {
        return XPathFactory.newInstance().newXPath().compile(xpath);
    }
}