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.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

public class Main {
    /**
     * convenience method to generate an XPathExpression object from a string representing an Xpath
     * @param pathstring the string
     * @return an Xpath object, or null if there was an exception
     */
    public static XPathExpression makeXPathFromString(String pathstring) {
        XPathFactory factory = XPathFactory.newInstance();
        XPath xpath = factory.newXPath();
        XPathExpression expr = null;
        try {
            expr = xpath.compile(pathstring);
        } catch (XPathExpressionException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();

        }
        return expr;
    }
}