PHPHtmlParser\Dom::loadStr PHP Method

loadStr() public method

Parsers the html of the given string. Used for load(), loadFromFile(), and loadFromUrl().
public loadStr ( string $str, array $option )
$str string
$option array
    public function loadStr($str, $option)
    {
        $this->options = new Options();
        $this->options->setOptions($this->globalOptions)->setOptions($option);
        $this->rawSize = strlen($str);
        $this->raw = $str;
        $html = $this->clean($str);
        $this->size = strlen($str);
        $this->content = new Content($html);
        $this->parse();
        $this->detectCharset();
        return $this;
    }

Usage Example

Beispiel #1
0
 private function generateHtmlFields($response)
 {
     $dom = new Dom();
     $dom->loadStr($response, array());
     $contents = $dom->find('.caixacampobranco')[0];
     if ($contents === null) {
         return false;
     }
     $fields = $contents->find('span');
     return $fields;
 }