Java XML QName read(Node node, String expression, QName returnType)

Here you can find the source of read(Node node, String expression, QName returnType)

Description

read

License

Open Source License

Declaration

public static Object read(Node node, String expression, QName returnType) throws XPathExpressionException 

Method Source Code

//package com.java2s;
/*/*from w w w. j a v  a  2 s. c o m*/
 *
 * This 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; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software 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 this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

import javax.xml.namespace.QName;
import javax.xml.xpath.XPath;
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 Object read(Node node, String expression, QName returnType) throws XPathExpressionException {
        XPath xpath = XPathFactory.newInstance().newXPath();
        XPathExpression xPathExp = xpath.compile(expression);
        return xPathExp.evaluate(node, returnType);
    }
}

Related

  1. moveReaderToTag(XMLStreamReader reader, QName... tags)
  2. namedNode(QName qname)
  3. nodeToQName(Node node)
  4. parseXml(final Node node, final Map properties)
  5. printPath(List path)
  6. readTextElement(XMLEventReader reader, QName elemName)
  7. resolveNamespace(String qname, Node xml)
  8. resolveQName(final Element el, final String qualifiedName)
  9. resolveQName(String qNameWithPrefix, Element element)