I'm trying to find paragraphs with the id "test" and remove them from a html string, I've tried using php DOMDocument but the html I'm searching is badly formed and I get errors
$caption = "blah blah<p id ='test'>Test message</p>";
$doc = new DOMDocument();
$doc->loadHTMLFile($caption);
$xmessage = $doc->getElementById('test');
returns
Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Unexpected end tag : br i
Is there a way to suppress the warnings? Thanks