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

public class Main {
    public static Node findSchemaPropertyByDimensionName(Document xmlDoc, String xPathExpression) {
        XPath xPath = XPathFactory.newInstance().newXPath();

        Node nOde = null;
        try {
            nOde = (Node) xPath.compile(xPathExpression).evaluate(xmlDoc, XPathConstants.NODE);
        } catch (XPathExpressionException e) {
            e.printStackTrace();
        }
        return nOde;
    }
}