Problem with invalid XML/HTML in PHP DOM

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

Suppose you have the following HTML:


You want to load it into a

2条回答
  •  野趣味
    野趣味 (楼主)
    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.

提交回复
热议问题