Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    private static XPath _xpath = XPathFactory.newInstance().newXPath();

    /**
     * Use the supplied XPath statement find the data.
     * 
     */
    public static String findString(Document document, String xpath) {
        try {
            return (String) _xpath.evaluate(xpath, document, XPathConstants.STRING);
        } catch (XPathExpressionException e) {
            e.printStackTrace();
        }
        return null;
    }
}