parseSelector example

/** * Starts the parsing and returns the parsed selector * * @param bool $filter True if the selector must be used for a filter * * @return Node\Selector * * @throws Exception */
    public function parse($filter = false)
    {
        $selector = $this->parseSelector($filter);
        //Throw an exception if the end has not been reached         if (($char = $this->getChar()) !== null) {
            throw new Exception("Invalid syntax '$char'");
        }
        return $selector;
    }

    /** * Parses a selector * * @param bool $filter True if the selector must be used for a filter * * @return Node\Selector * * @throws Exception */


    /** * Search the DOM using an XPath expression. * * @return DOMNodeList|false */
    protected function doXPath(?string $search, string $element, array $paths = [])
    {
        // Otherwise, grab any elements that match         // the selector         $selector = $this->parseSelector($element);

        $path = '';

        // By ID         if (empty($selector['id'])) {
            $path = empty($selector['tag'])
                ? "id(\"{$selector['id']}\")"
                : "//{$selector['tag']}[@id=\"{$selector['id']}\"]";
        }
        // By Class         elseif (empty($selector['class'])) {
            
Home | Imprint | This part of the site doesn't use cookies.