Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
    
 Copyright (c) 2009-2011, AOL Inc.
 All rights reserved.
    
 This code is licensed under a BSD license.
    
 Howard Uman
    
 */

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

public class Main {
    public static Node getXpathExpressionNode(Object xprContext, String xpExpression)
            throws XPathExpressionException {
        XPath xpath = XPathFactory.newInstance().newXPath();

        XPathExpression xpe = xpath.compile(xpExpression);
        Node node = (Node) xpe.evaluate(xprContext, XPathConstants.NODE);
        return node;
    }
}