src/Dev/CSSContentParser.php
public function selector2xpath($selector)
    {
        $parts = preg_split('/\\s+/', $selector);
        $xpath = "";
        foreach ($parts as $part) {
            if (preg_match('/^([A-Za-z][A-Za-z0-9]*)/', $part, $matches)) {
                $xpath .= "//$matches[1]";
            } else {
                $xpath .= "//*";
            }
            $xfilters = array();
            if (preg_match('/#([^#.\[]+)/', $part, $matches)) {
                $xfilters[] = "@id='$matches[1]'";
            }
            if (preg_match('/\.([^#.\[]+)/', $part, $matches)) {
                $xfilters[] = "contains(@class,'$matches[1]')";
            }
            if ($xfilters) {
                $xpath .= '[' . implode(',', $xfilters) . ']';
            }
        }
        return $xpath;
    }
public function selector2xpath($selector)
    {
        $parts = preg_split('/\\s+/', $selector);
        $xpath = "";
        foreach ($parts as $part) {
            if (preg_match('/^([A-Za-z][A-Za-z0-9]*)/', $part, $matches)) {
                $xpath .= "//$matches[1]";
            } else {
                $xpath .= "//*";
            }
            $xfilters = array();
            if (preg_match('/#([^#.\[]+)/', $part, $matches)) {
                $xfilters[] = "@id='$matches[1]'";
            }
            if (preg_match('/\.([^#.\[]+)/', $part, $matches)) {
                $xfilters[] = "contains(@class,'$matches[1]')";
            }
            if ($xfilters) {
                $xpath .= '[' . implode(',', $xfilters) . ']';
            }
        }
        return $xpath;
    }
public function selector2xpath ( $ selector ) { $ parts = preg_split ( '/\\s+/' , $ selector ) ; $ xpath = "" ; foreach ( $ parts as $ part ) { if ( preg_match ( '/^([A-Za-z][A-Za-z0-9]*)/' , $ part , $ matches ) ) { $ xpath .= "//$matches[1]" ; } else { $ xpath .= "//*" ; } $ xfilters = array ( ) ; if ( preg_match ( '/#([^#.\[]+)/' , $ part , $ matches ) ) { $ xfilters [ ] = "@id='$matches[1]'" ; } if ( preg_match ( '/\.([^#.\[]+)/' , $ part , $ matches ) ) { $ xfilters [ ] = "contains(@class,'$matches[1]')" ; } if ( $ xfilters ) { $ xpath .= '[' . implode ( ',' , $ xfilters ) . ']' ; } } return $ xpath ; }
Converts a CSS selector into an equivalent xpath expression.
Currently the selector engine only supports querying by tag, id, and class.

@param String $selector See {@link getBySelector()}
@return String XPath expression
Converts a CSS selector into an equivalent xpath expression . Currently the selector engine only supports querying by tag id and class .