Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.xml.namespace.QName;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

public class Main {
    public static String selectString(String xpath, Object node) {
        return ((String) evaluateXPath(xpath, node, XPathConstants.STRING)).trim();
    }

    public static Object evaluateXPath(String xpath, Object item, QName returnType) {
        try {
            return XPathFactory.newInstance().newXPath().compile(xpath).evaluate(item, returnType);
        } catch (XPathExpressionException e) {
            throw new IllegalArgumentException(e);
        }
    }
}