How to ignore CDATA tags?

Posted by Petre on Stack Overflow See other posts from Stack Overflow or by Petre
Published on 2012-03-24T19:58:23Z Indexed on 2012/03/27 11:29 UTC
Read the original article Hit count: 333

Filed under:
|
|

I'm trying to make an html parser, but when I load the html I get warnings like this

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Invalid char in CDATA 0x1C in Entity, line: 1302

Here is the code I use

class Parser
{
public $url=null;
public $html=null;
public $tidy=null;
public $head=null;
public $head_xpath=null;


function __construct($url){
    $this->url=$url;
    $this->html=file_get_contents($this->url);
    $this->tidy=tidy_parse_string($this->html);
    $this->head=new DOMDocument();
    $this->head->loadHTML($this->tidy->head());
    $this->head_xpath= new DOMXPath($this->head);

}
}

$x=new Parser("http://www.guardian.co.uk/politics/2012/mar/24/vince-cable-coalition-banking-row");

I searched around and found the LIBXML_NOCDATA constant, but I don't know how to set it. So how could i completely ignore CDATA?

© Stack Overflow or respective owner

Related posts about php

Related posts about cdata