Symfony\Component\DomCrawler\Crawler::nodeName PHP Method

nodeName() public method

Returns the node name of the first node of the list.
public nodeName ( ) : string
return string The node name
    public function nodeName()
    {
        if (!$this->nodes) {
            throw new \InvalidArgumentException('The current node list is empty.');
        }
        return $this->getNode(0)->nodeName;
    }

Usage Example

コード例 #1
0
ファイル: Base.php プロジェクト: ssnepenthe/recipe-scraper
 protected function looksLikeGroupTitle(Crawler $node)
 {
     $tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'strong', 'dt'];
     if (in_array($node->nodeName(), $tags)) {
         return true;
     }
     if (preg_match('/[#\\*\\-_=\\+]{2,}/', $node->text())) {
         return true;
     }
     if (':' === substr($node->text(), -1)) {
         return true;
     }
     if (false !== strpos($node->attr('class'), 'header')) {
         return true;
     }
     if (false !== strpos($node->attr('class'), 'title')) {
         return true;
     }
     return false;
 }
All Usage Examples Of Symfony\Component\DomCrawler\Crawler::nodeName