Get the first node matching an XPath query, or null if no match.

@param string $path
@return QuiteSimpleXMLElement
517146
public function first($path)
    {
        // Convenience method
        $x = $this->xpath($path);

        return count($x) ? $x[0] : null;
    }
638739
public function xpath($path)
    {
        $xpath = new \DOMXPath($this->dom);

        $list = $xpath->query($path);

        $return = [];
        foreach ($list as $node) {
            $return[] = $this->newElement($node);
        }

        return $return;
    }
744430
public function getFinder($path = '')
    {
        if (($protocol = array_search($this, self::$registeredWrappers))
            === false
        ) {
            $protocol = $this->registerStreamWrapper(null);
        }

        $path   = sprintf(
            "%s://%s/%s",
            $protocol,
            $this->getBucket(),
            $this->applyPathPrefix($path)
        );
        $finder = new Finder();
        $finder->in($path);

        return $finder;
    }
471188
protected function getContent($path)
    {
        if (null === self::$root) {
            return null;
        }

        if (self::$root->getName() === $path) {
            return self::$root;
        }

        if (self::$root->hasChild($path) === true) {
            return self::$root->getChild($path);
        }

        return null;
    }
748096
private function readNode($path)
    {
        $finder = new Finder($path);

        if(false !== $finder->getPropertiesPath())
        {
            $uri = str_replace($this->contentPath, '', $path);
            $uri = $uri ? $uri : '/';
            $properties = PropertiesParser::parse($finder);
            $node = new Node($properties['name'], $uri);

            //Add child nodes and link references
            $index = 0;
            foreach (SortorderParser::parse($finder) as $subPath)
            {
                $child = $this->readNode($path . DIRECTORY_SEPARATOR . $subPath);
                $node->addChildAsLast($child);
                $child->setParent($node);

                if($index)
                {
                    $child->setPrev($node->getChildByIndex($index - 1));
                    $node->getChildByIndex($index - 1)->setNext($child);
                }

                $index++;
            }

            //Set properties and set tree_ properties to nodes
            foreach ($properties['properties'] as $key => $value)
            {
                $node->setProperty($key, $value);
            }

            return $node;
        }

        throw new \Coral\SiteBundle\Exception\SitemapException("Unable to find properties for: [$path]");
    }
81438
public function getElementForPath( string $path )
	{
		$path = trim( $path, '/' );
		$parts = explode( '/', $path );

		$current = &$this->contents;

		foreach ( $parts as $part )
		{
			if ( isset( $current[ $part ] ) )
			{
				$current = &$current[ $part ];
				continue;
			}

			return false;

			return in_array( $part, $current )
				? $current
				: false;
		}

		return $current;
	}
91439
protected function findElementXpaths($xpath) {
    $elements = $this->browser->find("xpath", $xpath);
    $nodeXPaths = array();

    if (!isset($elements["ids"])) {
      return array();
    }

    foreach ($elements["ids"] as $i => $elementId) {
      $nodeXPaths[] = sprintf('(%s)[%d]', $xpath, $i + 1);
    }
    return $nodeXPaths;
  }
208067
public function deleteNode($path)
	 {
	 	if(!$this->zookeeper->exists($path))
	 	{
	 		return null;
	 	}
	 	else
	 	{
	 		return $this->zookeeper->delete($path);
	 	}
	 }
956996
public function find($path)
    {
        foreach (array_keys($this->pathLookupTable) as $key) {
            if (starts_with($path, $key)) {
                return $key;
            }
        }
    }
5297
private function parsePath($path)
    {
        $parts = array(
            'template' => null,
            'path' => null,
        );

        // strip out any query params
        if (preg_match('/^\/?(.*?)\/(.*)/', $path, $matches)) {
            $parts['template'] = $matches[1];
            $parts['path'] = $matches[2];
        }

        return $parts;
    }
407510
public static function getValueFromXPath($path, \DOMXPath $xpath, \DomNode $context = null, $default = null)
    {
        $result = $xpath->query($path, $context);
        if (0 === $result->length) {
            return $default;
        }

        $item = $result->item(0);
        if (null === $item) {
            return $default;
        }

        return $item->nodeValue;
    }
1121715
public function getChild($path)
	{
		$path    = str_replace(array('/', '\\'), '\\', $path);
		$names   = explode('\\', $path);
		$command = $this;

		foreach ($names as $name)
		{
			if (isset($command[$name]))
			{
				$command = $command[$name];

				continue;
			}

			return null;
		}

		return $command;
	}
1218785
public function extract($path) {

        if (empty($path)) {
            return $this->props;
        }
        // Simple paths.
        if (!preg_match('/[{\[]/', $path)) {
            return (array)$this->get($path);
        }
        if (strpos($path, '[') === false) {
            $tokens = explode('/', $path);
        } else {
            $tokens = $this->_tokenize($path, '/', '[', ']');
        }
        $_key = '__set_item__';
        $context = array($_key => array($this->props));
        foreach ($tokens as $token) {
            $next = array();
            list($token, $conditions) = $this->_splitConditions($token);
            foreach ($context[$_key] as $item) {
                foreach ((array)$item as $k => $v) {
                    if ($this->_matchToken($k, $token)) {
                        $next[] = $v;
                    }
                }
            }
            // Filter for attributes.
            if ($conditions) {
                $filter = array();
                foreach ($next as $item) {
                    if (is_array($item) && $this->_matches($item, $conditions)) {
                        $filter[] = $item;
                    }
                }
                $next = $filter;
            }
            $context = array($_key => $next);
        }
        return $context[$_key];
    }
909256
public function getChildPageByPath($path)
    {
        $page = $this;
        $pathParts = preg_split('#([/:])#', $path, -1, PREG_SPLIT_DELIM_CAPTURE);
        for($i=0; $i<count($pathParts); $i++) {
            $pathPart = $pathParts[$i];
            $i++;
            $nextSeparator = isset($pathParts[$i]) ? $pathParts[$i] : '/';
            if ($nextSeparator == '/') {
                $pages = $page->getRecursiveChildComponents(array(
                                'filename' => $pathPart,
                                'pseudoPage'=>true,
                                'limit'=>1),
                            array('pseudoPage'=>false));
            } else {
                // if path is separated by ':', id comes without '-', search for child-component
                $pages = $page->getRecursiveChildComponents(array(
                                'id' => '-' . $pathPart,
                                'pseudoPage'=>false,
                                'limit'=>1),
                            array('pseudoPage'=>false));
            }
            $page = current($pages);
            if (!$page) break;
        }
        return $page;
    }
335858
public function get($path, $depth = 0)
    {
        $node = $this->nodeRepoForDepth($depth)->getByPathOrFail($path);
        return $this->ensureEloquentFile($node);
    }
711102
public function getNode($path)
    {
        $nodes = $this->getNodes($path);
        if ($nodes && ($nodes->length > 0)) {
            return $nodes->item(0);
        }

        return null;
    }
52079
private function detectFromPath($path)
    {
        if (!$this->usePath) {
            return null;
        }

        $first = \explode('/', \ltrim($path, '/'), 2)[0];
        $first = \strtolower($first);

        if (!empty($first) && \in_array($first, $this->languages, true)) {
            return $first;
        }

        return null;
    }