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

html() public method

Returns the first node of the list as HTML.
public html ( ) : string
return string The node html
    public function html()
    {
        if (!$this->nodes) {
            throw new \InvalidArgumentException('The current node list is empty.');
        }
        $html = '';
        foreach ($this->getNode(0)->childNodes as $child) {
            $html .= $child->ownerDocument->saveHTML($child);
        }
        return $html;
    }

Usage Example

コード例 #1
0
 /**
  * @param Crawler $node
  *
  * @return array
  */
 protected function parse(Crawler $node)
 {
     $title = explode(' - ', $node->html());
     // Get the changes
     $nodes = $node->nextAll()->filterXPath('h3[preceding-sibling::h2[1][.="' . $node->html() . '"]]');
     $changes = (new ChangesRetriever($nodes))->retrieve();
     return ['name' => $title[0], 'date' => isset($title[1]) ? $title[1] : null, 'changes' => $changes];
 }
All Usage Examples Of Symfony\Component\DomCrawler\Crawler::html