Zend Framework dom problem

I want to get the website shortcut icon (favicon) and styles path with zend_dom request

$dom = new Zend_Dom_Query($html); 
$stylesheet = $dom->query('link[rel="stylesheet"]');
$shortcut = $dom->query('link[rel="shortcut icon"]');

The style sheet query works, but the shortcut icon does not work. How am i doing this?

Thank.

+3
source share
1 answer

This is apparently a problem with the implementation of the Zend css style query. In Zend / Dom / Query.php, the query function calls the conversion function to convert the query to the correct xpath format:

public function query($query)
{
    $xpathQuery = Zend_Dom_Query_Css2Xpath::transform($query);
    return $this->queryXpath($xpathQuery, $query);
}

However, in the method, transform()they seem to use some pretty basic regular expression to separate the string with spaces:

$segments = preg_split('/\s+/', $path);

This basically means that your request link[rel="shortcut icon"]now becomes two requests: link[rel="shortcutandicon"]

, Zend_Dom_Query::queryXpath() xPath. :

$dom->queryXpath('//link[@rel="shortcut icon"]');
+3

Source: https://habr.com/ru/post/1727715/


All Articles