Executes the specified namespace aware XPath query as a multiple node query, returning the resulting list of nodes.
976938
@SuppressWarnings("unchecked")
    public static List<Node> selectNodes(Node node, String xpathQuery, Map<String, String> namespaceUris) {
        XPath xpath = DocumentHelper.createXPath(xpathQuery);
        xpath.setNamespaceURIs(namespaceUris);

        return xpath.selectNodes(node);
    }
1340647
public static function getFirstElementValueByXpath($node, $xpath_query, $namespaces = array())
    {
        $node = XMLTool :: getFirstElementByXpath($node, $xpath_query, $namespaces);

        if (isset($node))
        {
            return $node->nodeValue;
        }
        else
        {
            return null;
        }
    }
903828
def xpath(self, expression):
        
        self.__expression = expression
        self.__namespaces = XPATH_NAMESPACES
        return self.__doc.xpath(self.__expression, namespaces=self.__namespaces)
1269300
def query(wosclient, wos_query, xml_query=None, count=5, offset=1, limit=100):
    """"""
    results = [single(wosclient, wos_query, xml_query, min(limit, count-x+1), x)
               for x in range(offset, count+1, limit)]
    if xml_query:
        return [el for res in results for el in res]
    else:
        pattern = _re.compile(r'^<\?xml.*?\n<records>\n|\n</records>$.*')
        return ('<?xml version="1.0" ?>\n<records>' +
                '\n'.join(pattern.sub('', res) for res in results) +
                '</records>')
910680
public NodeList getMatchingNodes(String select, Document document)
        throws XpathException {
        try {
            return new NodeListForIterable(engine
                                           .selectNodes(select,
                                                        new DOMSource(document))
                                           );
        } catch (XMLUnitException ex) {
            throw new XpathException(ex.getCause());
        }
    }
578270
def get_element_by_xpath(self, xpath_str, namespaces=None):
        
        try:
            return self._root_el.findall('.' + xpath_str, namespaces)
        except (ValueError, xml.etree.ElementTree.ParseError) as e:
            raise SimpleXMLWrapperException(
                'XPath select raised exception. xpath_str="{}" error="{}"'.format(
                    xpath_str, str(e)
                )
            )
1000620
public static function getFirstElementByXpath($node, $xpath_query, $namespaces = array())
    {
        if(is_a($node, 'DOMDocument'))
        {
            $xpath = new DOMXPath($node);
        }
        elseif(is_a($node, 'DOMNode'))
        {
            $xpath = new DOMXPath($node->ownerDocument);
        }
        else
        {
            return null;
        }

        foreach($namespaces as $prefix => $namespaceURI)
        {
            $xpath->registerNamespace($prefix, $namespaceURI);
        }

        $node_list = $xpath->query($xpath_query, $node);

        if ($node_list->length > 0)
        {
            return $node_list->item(0);
        }
        else
        {
            return null;
        }
    }
168281
private @Nonnull NodeList evaluate(String xpath) {
        try {
            XPathExpression expr = xpf.newXPath().compile(xpath);
            return (NodeList) expr.evaluate(node, XPathConstants.NODESET);
        } catch (XPathExpressionException ex) {
            throw new IllegalArgumentException("Invalid XPath '" + xpath + "'", ex);
        }
    }
992921
def query(self, name, node):
        
        #log.debug('searching schema for (%s)', name)
        qref = qualify(name, node, node.namespace())
        query = BlindQuery(qref)
        result = query.execute(self.schema)
        return (result, [])
1321645
private function getArrayFromElementsByTagName ($rawXml, $tag, $namespace = NULL) {
		// Get DOM instance and load XML
		$dom = new \DOMDocument();

		$dom->loadXML($rawXml, (LIBXML_VERSION >= 20900) ? LIBXML_PARSEHUGE : null);

		// Is namespace set?
		if (!is_null($namespace)) {
			// Use it
			$nodes = $dom->getElementsByTagNameNS($tag, $namespace);
		} else {
			// Get nodes
			$nodes = $dom->getElementsByTagName($tag);
		}

		// Return nodes list
		return $nodes;
	}
1025128
@Override
  public Iterator<String> getPrefixes(String namespaceURI) {
    // per javax.xml.namespace.NamespaceContext doc
    if (namespaceURI == null)
      throw new IllegalArgumentException("Cannot find prefix for null namespace URI");

    List<String> list = new ArrayList<>();
    if (XMLConstants.XML_NS_URI.equals(namespaceURI))
      list.add(XMLConstants.XML_NS_PREFIX);
    else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI))
      list.add(XMLConstants.XMLNS_ATTRIBUTE);
    else
      for (Map.Entry<String, String> entry: bindings.entrySet()) {
        if (namespaceURI.equals(entry.getValue()))
          list.add(entry.getKey());
      }

    return Collections.unmodifiableList(list).iterator();
  }
541345
def namespace_inclusion_builder(namespace: Strings) -> NodePredicate:
    """"""
    if isinstance(namespace, str):
        def namespace_filter(_: BELGraph, node: BaseEntity) -> bool:
            """Pass only for a node that has the enclosed namespace."""
            return NAMESPACE in node and node[NAMESPACE] == namespace

    elif isinstance(namespace, Iterable):
        namespaces = set(namespace)

        def namespace_filter(_: BELGraph, node: BaseEntity) -> bool:
            """Pass only for a node that has a namespace in the enclosed set."""
            return NAMESPACE in node and node[NAMESPACE] in namespaces

    else:
        raise TypeError('Invalid type for argument: {}'.format(namespace))

    return namespace_filter
75744
def xpath(C, node, path, namespaces=None, extensions=None, smart_strings=True, **args):
        """"""
        return node.xpath(
            path,
            namespaces=namespaces or C.NS,
            extensions=extensions,
            smart_strings=smart_strings,
            **args
        )
227887
def get_subtree(self, tree, xpath_str):
        """"""
        return tree.xpath(xpath_str, namespaces=self.namespaces)
1190329
def child_xpath(ns, element_name, attributes=nil)
      ns_uri = ns.is_a?(Namespace) ? ns.uri : ns
      unless !attributes.nil? && attributes.is_a?(Hash)
        "child::*[local-name()='#{element_name}' and namespace-uri()='#{ns_uri}']"
      else
        attr_str = attributes.collect{|key, val| "@#{key.to_s}='#{val}'"}.join(' and ')
        "child::*[local-name()='#{element_name}' and namespace-uri()='#{ns_uri}' and #{attr_str}]"
      end
    end
1187631
def xpath(self, expression):
        """"""
        global namespaces
        return self.tree.xpath(expression, namespaces=namespaces)
470911
protected function xpath($query, DOMNode $node = null)
	{
		$query = str_replace('$XSL', '"' . self::XMLNS_XSL . '"', $query);

		return iterator_to_array($this->xpath->query($query, $node));
	}