Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import org.w3c.dom.Document;

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

public class Main {
    public static String evalXPath(String path, Document doc) {
        XPath xpath = newXPath();
        try {
            return xpath.evaluate(path, doc);
        } catch (XPathExpressionException e) {
            throw new RuntimeException(e);
        }
    }

    public static XPath newXPath() {
        XPathFactory factory = XPathFactory.newInstance();
        XPath xpath = factory.newXPath();
        return xpath;
    }
}