Here you can find the source of selectNodes(String xpath, Object node)
Parameter | Description |
---|---|
xpath | a parameter |
node | a parameter |
public static NodeList selectNodes(String xpath, Object node)
//package com.java2s; /*// w ww.j a v a 2 s . c o m * Movie Renamer * Copyright (C) 2014 Nicolas Magr? * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.NodeList; public class Main { /** * Select all children node of a xpath * * @param xpath * @param node * @return */ public static NodeList selectNodes(String xpath, Object node) { try { return (NodeList) getXPath(xpath).evaluate(node, XPathConstants.NODESET); } catch (Exception e) { throw new RuntimeException(e); } } private static XPathExpression getXPath(String xpath) throws XPathExpressionException { return XPathFactory.newInstance().newXPath().compile(xpath); } }