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 javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.*;

public class Main {
    public static NodeList selectNodeList(Node xml, String xPath) throws Exception {
        XPath xpath = XPathFactory.newInstance().newXPath();
        XPathExpression expr = xpath.compile(xPath);
        NodeList nodeList = (NodeList) expr.evaluate(xml, XPathConstants.NODESET);
        return nodeList;
    }
}