Metodo que permite buscar elementos hijos a partir de un selector css.
@param  string $css_selector Cadena de texto con el selector css.
@return PHPTools\PHPHtmlDom\Core\PHPHtmlDomList
760364
final public function e($css_selector)
    {
        $xpath = $this->toXPath($css_selector);

        if(!!$xpath)
        {
            return new \PHPTools\PHPHtmlDom\Core\PHPHtmlDomList($this->xpath->query($xpath));
        }
    }
956927
def all_selectors(Class, fn):
        """"""
        selectors = []
        cssparser = cssutils.CSSParser(validate=False)
        css = cssparser.parseFile(fn)
        for rule in [r for r in css.cssRules if type(r)==cssutils.css.CSSStyleRule]:
            selectors += [sel.selectorText for sel in rule.selectorList]
        selectors = sorted(list(set(selectors)))
        return selectors
404228
function createSelectorList() {
        var doc = DocumentManager.getCurrentDocument();
        if (!doc) {
            return;
        }

        var docText = doc.getText();
        return CSSUtils.extractAllSelectors(docText, doc.getLanguage().getMode());
    }
1225000
protected function getSelector(): DocumentSelector
    {
        if (empty($this->selector)) {
            //Requesting selector on demand
            $this->selector = $this->odm->selector($this->class);
        }

        return clone $this->selector;
    }
128548
def _css_select(soup, css_selector):
        
        selection = soup.select(css_selector)
        if len(selection) > 0:
            if hasattr(selection[0], 'text'):
                retour = selection[0].text.strip()
            else:
                retour = ""
        else:
            retour = ""
        return retour
795479
public function addQueryByCss($expression)
    {
        $pieces = explode(' ', $expression);
        foreach ($pieces as $piece) {
            $isTag = true;
            if (preg_match('/\./is', $piece)) {
                $pieceSplit = explode(".", $piece);
                $selector = empty($pieceSplit[0]) ? "*" : $pieceSplit[0];
                $class = $pieceSplit[1];
                $this->addQueryByClass($class, $selector);
                $isTag = false;
            }
            if (preg_match('/\#/is', $piece)) {
                $pieceSplit = explode("#", $piece);
                $selector = empty($pieceSplit[0]) ? "*" : $pieceSplit[0];
                $id = $pieceSplit[1];
                $this->addQueryById($id, $selector);
                $isTag = false;
            }
            if ($isTag) {
                $this->addQueryBySelector($piece);
            }
        }

        return $this;
    }
77059
public function setSelector($css_selector)
    {
        // if # is the first sign - we start with ID.
        if (0 === strpos($css_selector, '#')) {
            $css_selector .= '.'; // prevent empty second part.
            list($id, $class) = explode('.', $css_selector, 2);
        } else {
            $css_selector .= '#'; // prevent empty second part.
            list($class, $id) = explode('#', $css_selector, 2);
        }

        $id = trim($id, '#');
        $class = trim($class, '.');

        if (! empty($id)) {
            $this->setAttr('id', $id);
        }

        if (! empty($class)) {
            $class = str_replace('.', ' ', $class);
            $this->setAttr('class', $class);
        }

        return $this;
    }
713040
public function extract_first($css, $rules)
    {
        $nodes = $this->_document->getQuery()->css($css);

        if ($nodes) {
            return (new static($this->_document, $nodes->item(0)))->extract($rules);
        } else {
            return [];
        }
    }
1099073
public static function getSegments($selector)
    {
        $selector = trim($selector);

        if ($selector === '') {
            throw new InvalidSelectorException('The selector must not be empty');
        }

        $tag = '(?P<tag>[\*|\w|\-]+)?';
        $id = '(?:#(?P<id>[\w|\-]+))?';
        $classes = '(?P<classes>\.[\w|\-|\.]+)*';
        $attrs = '(?P<attrs>(?:\[.+?\])*)?';
        $name = '(?P<pseudo>[\w\-]+)';
        $expr = '(?:\((?P<expr>[^\)]+)\))';
        $pseudo = '(?::'.$name.$expr.'?)?';
        $rel = '\s*(?P<rel>>)?';

        $regexp = '/'.$tag.$id.$classes.$attrs.$pseudo.$rel.'/is';

        if (preg_match($regexp, $selector, $segments)) {
            if ($segments[0] === '') {
                throw new InvalidSelectorException(sprintf('Invalid selector "%s"', $selector));
            }

            $result['selector'] = $segments[0];

            if (isset($segments['tag']) && $segments['tag'] !== '') {
                $result['tag'] = $segments['tag'];
            }

            // if the id attribute specified
            if (isset($segments['id']) && $segments['id'] !== '') {
                $result['id'] = $segments['id'];
            }

            // if the attributes specified
            if (isset($segments['attrs'])) {
                $attributes = trim($segments['attrs'], '[]');
                $attributes = explode('][', $attributes);

                foreach ($attributes as $attribute) {
                    if ($attribute !== '') {
                        list($name, $value) = array_pad(explode('=', $attribute, 2), 2, null);

                        if ($name === '') {
                            throw new InvalidSelectorException(sprintf('Invalid selector "%s": attribute name must not be empty', $selector));
                        }

                        // equal null if specified only the attribute name
                        $result['attributes'][$name] = is_string($value) ? trim($value, '\'"') : null;
                    }
                }
            }

            // if the class attribute specified
            if (isset($segments['classes'])) {
                $classes = trim($segments['classes'], '.');
                $classes = explode('.', $classes);

                foreach ($classes as $class) {
                    if ($class !== '') {
                        $result['classes'][] = $class;
                    }
                }
            }

            // if the pseudo class specified
            if (isset($segments['pseudo']) && $segments['pseudo'] !== '') {
                $result['pseudo'] = $segments['pseudo'];

                if (isset($segments['expr']) && $segments['expr'] !== '') {
                    $result['expr'] = $segments['expr'];
                }
            }

            // if it is a direct descendant
            if (isset($segments['rel'])) {
                $result['rel'] = $segments['rel'];
            }

            return $result;
        }

        throw new InvalidSelectorException(sprintf('Invalid selector "%s"', $selector));
    }
1272699
protected function getRanges(string $selector): Collection
    {
        return Factory::create(explode(';', $selector))->map(
            function ($range) {
                $separator = $this->dotDotSeparator($range);
                if (false != $separator) {
                    return Factory::create([(int) substr($range, 0, $separator), (int) substr($range, $separator + 2)]);
                }
                $separator = $this->columnSeparator($range);
                if (false != $separator) {
                    return Factory::create([(int) substr($range, 0, $separator), (int) substr($range, $separator + 1)]);
                }
                $separator = $this->dashSeparator($range);
                if (false != $separator) {
                    return Factory::create([(int) substr($range, 0, $separator), (int) substr($range, $separator + 1)]);
                }
                $separator = $this->commaSeparator($range);
                if (false != $separator) {
                    return Factory::create(
                        [
                            (int) substr($range, 0, $separator),
                            (int) substr($range, 0, $separator) + (int) (substr($range, $separator + 1) - 1),
                        ]
                    );
                }

                // just a number here
                return Factory::create([(int) $range, (int) $range]);
            }
        );
    }
821641
protected function multiplySelectors($selectors)
    {
        // find parent selectors

        $parentSelectors = $this->findClosestSelectors();
        if (is_null($parentSelectors)) {
            // kill parent reference in top level selector
            foreach ($selectors as &$s) {
                $this->expandParentSelectors($s, '');
            }

            return $selectors;
        }

        $out = array();
        foreach ($parentSelectors as $parent) {
            foreach ($selectors as $child) {
                $count = $this->expandParentSelectors($child, $parent);

                // don't prepend the parent tag if & was used
                if ($count > 0) {
                    $out[] = trim($child);
                } else {
                    $out[] = trim($parent.' '.$child);
                }
            }
        }

        return $out;
    }
1246321
public function remove($selector=null)
    {
        $result = $this;
        if ($selector) {
            $result = $result->filter($selector);
        }
        foreach ($result->nodes as $node) {
            if ($node->parentNode) {
                $node->parentNode->removeChild($node);
            }
        }

        $result->nodes = array();
        $result->length = 0;

        return $result;
    }
1335252
public function split($css = null, $part = 1, $maxSelectors = self::MAX_SELECTORS_DEFAULT)
	{
		if (empty($css) && empty($this->css)) {
			return null;
		}

		if (!empty($css) && $this->css !== $css) {
			$this->css = $css;
		}

		$charset = $this->extractCharset($this->css);
		isset($charset) && $this->css = str_replace($charset, '', $this->css);
		if (empty($this->css)) {
			return null;
		}

		$this->parsedCss = $this->splitIntoBlocks($this->css);
		if (empty($this->parsedCss)) {
			return null;
		}

		$output    = $charset ? : '';
		$count     = 0;
		$partCount = 1;
		foreach ($this->parsedCss as $block) {
			$appliedMedia = false;
			foreach ($block['rules'] as $rule) {
				$tmpCount = $rule['count'];

				// we have a new part so let's reset and increase
				if (($count + $tmpCount) > $maxSelectors) {
					$partCount++;
					$count = 0;
				}

				$count += $tmpCount;
				if ($partCount < $part) {
					continue;
				}
				if ($partCount > $part) {
					break;
				}

				if (!$appliedMedia && isset($block['at-rule'])) {
					$output .= $block['at-rule'] . ' {';
					$appliedMedia = true;
				}
				$output .= $rule['rule'];
			}
			$appliedMedia && $output .= '}';
		}

		return $output;
	}
996342
public static function cssToArray($css){
        if(!$css) {
            return array();
        }
        $css = str_replace(' /* Do not edit */', '', $css);
        $oldCssArr = explode("\n", $css);
        $newCssArr = array();
        foreach($oldCssArr as $line) {
            if(false === strpos($line, '{')) {
                continue;
            }

            preg_match('~(?P<selector>[^{]+)(\{)(?P<rules>[^}]+)\}~', $line, $matches);

            foreach($matches as $key => &$match){
                if(is_numeric($key)) {
                    continue;
                }
                $match = trim($match);
                if($key === 'rules') {
                    $ruleSet = array_filter(array_map('trim', explode(';', $match)));
                    $match = array();
                    foreach($ruleSet as $rule) {
                        $rule = array_map('trim', explode(':', $rule));
                        $match[$rule[0]] = $rule[1];
                    }
                }
            }

            $newCssArr[$matches['selector']] = $matches['rules'];
        }
        return $newCssArr;
    }
1322311
private function getCssSelectorPrecedence($selector)
    {
        $selectorKey = \md5($selector);
        if (!isset($this->caches[static::CACHE_KEY_SELECTOR][$selectorKey])) {
            $precedence = 0;
            foreach ($this->selectorPrecedenceMatchers as $matcher => $value) {
                if (\trim($selector) === '') {
                    break;
                }
                $number = 0;
                $selector = \preg_replace('/' . $matcher . '\\w+/', '', $selector, -1, $number);
                $precedence += ($value * $number);
            }
            $this->caches[static::CACHE_KEY_SELECTOR][$selectorKey] = $precedence;
        }

        return $this->caches[static::CACHE_KEY_SELECTOR][$selectorKey];
    }
733745
public static function selector($selector, $child = true){
		$css = '';
		if($selector->getType()){
			$css.= $selector->getType().' ';
		}
		if(!$selector->getTagName()&& !$selector->getIdentification() && !$selector->getClasses() && !$selector->getPseudos()){
			$css.= '*';
		}else{
			if($selector->getTagName()){
				$css.= $selector->getTagName();
			}
			if($selector->getAttributes()){
				$css.= implode('', $selector->getAttributes());
			}
			if($selector->getIdentification()){
				$css.= '#'.$selector->getIdentification();
			}
			if($selector->getClasses()){
				$css.= '.'.implode('.', $selector->getClasses());
			}
			if($selector->getPseudos()){
				$css.= ':'.implode(':', $selector->getPseudos());
			}
			if($child && $selector->getNext()){
				$css.= ' '.self::selector($selector->getNext(), true);
			}
		}
		return $css;
	}
1248604
public function children($selector=null)
    {
        $result = $this->createChildInstance();

        if (isset($this->document) && $this->length > 0) {
            if (isset($this->root_instance) || $this->getXpathQuery()) {
                foreach ($this->nodes as $node) {
                    if ($node->hasChildNodes()) {
                        $result->loadDomNodeList($node->childNodes);
                    }
                }
            } else {
                $result->loadDomNodeList($this->document->childNodes);
            }

            if ($selector !== false) { // filter out text nodes
                $filtered_elements = array();
                foreach ($result->getElements() as $result_elm) {
                    $filtered_elements[] = $result_elm;
                }
                $result->nodes = $filtered_elements;
                $result->length = \count($result->nodes);
            }

            if ($selector) {
                $result = $result->filter($selector);
            }
        }

        return $result;
    }