Here you can find the source of getSpeficValueFromNode(Node n, String xpathExpr)
public static String getSpeficValueFromNode(Node n, String xpathExpr) throws XPathExpressionException
//package com.java2s; /**/*from w w w . j a v a 2s . c om*/ * Copyright (c) 2010-2019 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 * * SPDX-License-Identifier: EPL-2.0 */ import java.util.Iterator; import javax.xml.namespace.NamespaceContext; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Node; public class Main { private static NamespaceContext ihcNamespaceContext = new NamespaceContext() { @Override public String getNamespaceURI(String prefix) { if (prefix == null) { throw new IllegalArgumentException("Prefix argument can't be null"); } else if ("SOAP-ENV".equals(prefix)) { return "http://schemas.xmlsoap.org/soap/envelope/"; } else if ("ns1".equals(prefix)) { return "utcs"; } return "utcs.values"; } @Override public String getPrefix(String uri) { return null; } @Override @SuppressWarnings("rawtypes") public Iterator getPrefixes(String uri) { throw new UnsupportedOperationException(); } }; public static String getSpeficValueFromNode(Node n, String xpathExpr) throws XPathExpressionException { XPath xpath = XPathFactory.newInstance().newXPath(); xpath.setNamespaceContext(ihcNamespaceContext); XPathExpression pathExpr = xpath.compile(xpathExpr); return (String) pathExpr.evaluate(n, XPathConstants.STRING); } }