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 org.w3c.dom.Document;

public class Main {
    /**
     * Evaluates a boolean xpath. Expensive as it creates a new xpath for every evaluation.
     */
    public static boolean evaluateBoolean(String xpathExpression, Document doc) throws XPathExpressionException {
        javax.xml.xpath.XPathFactory factory = javax.xml.xpath.XPathFactory.newInstance();
        XPath xpath = factory.newXPath();
        Boolean result = (Boolean) xpath.evaluate(xpathExpression, doc, XPathConstants.BOOLEAN);
        return result;
    }
}