Suppose you have the following HTML:
You want to load it into a
Can't you turn the html into a string, explode it and then stitch it back with the closing tag?
Try this:
$doc = new DOMDocument;
$doc->recover = true;
$doc->loadXml($response);
The $doc->recover = true
tells DOMDocument to try and parse non-well formed documents. See the documentation for more information.