Java XPath Select selectNodeList(Node node, String expression)

Here you can find the source of selectNodeList(Node node, String expression)

Description

select Node List

License

Open Source License

Declaration

public static NodeList selectNodeList(Node node, String expression) throws XPathExpressionException 

Method Source Code


//package com.java2s;
/*/*  w ww .  ja v  a2 s.  c  o m*/
 * Copyright (c) 2004-2012 The YAWL Foundation. All rights reserved.
 * The YAWL Foundation is a collaboration of individuals and
 * organisations who are committed to improving workflow technology.
 *
 * This file is part of YAWL. YAWL is free software: you can
 * redistribute it and/or modify it under the terms of the GNU Lesser
 * General Public License as published by the Free Software Foundation.
 *
 * YAWL is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
 * Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with YAWL. If not, see <http://www.gnu.org/licenses/>.
 */

import org.w3c.dom.*;

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

public class Main {
    public static NodeList selectNodeList(Node node, String expression) throws XPathExpressionException {
        XPathFactory factory = XPathFactory.newInstance();
        XPath path = factory.newXPath();
        Object result = path.evaluate(expression, node, XPathConstants.NODESET);
        return (NodeList) result;
    }
}

Related

  1. getValueFromXPath(Document document, String xpathString)
  2. getXmlElements(Document inXml, String xpath)
  3. selectElements(Element element, String xpathExpression)
  4. selectNodeIterator(Node nContextNode, String sXPath)
  5. selectNodeList(Node contextNode, String expression)
  6. selectNodes(final Node node, final String xPath)
  7. selectNodes(Node nodeParent, String name)
  8. selectNodes(String express, Object source)
  9. selectNodes(String xPath, Node target)