Problem with invalid XML/HTML in PHP DOM

后端 未结 2 2009
我寻月下人不归
我寻月下人不归 2021-01-27 17:09

Suppose you have the following HTML:


You want to load it into a

相关标签:
2条回答
  • 2021-01-27 17:38

    Can't you turn the html into a string, explode it and then stitch it back with the closing tag?

    0 讨论(0)
  • 2021-01-27 17:59

    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.

    0 讨论(0)
提交回复
热议问题