How to get full HTML from DOMXPath::query() method?

后端 未结 1 1310
小蘑菇
小蘑菇 2021-01-01 17:28

I have document from which I want to extract specific div with it\'s untouched content. I do:

$dom = new DOMDocument();
$dom->loadHTML($string);//that\'s          


        
相关标签:
1条回答
  • 2021-01-01 18:09

    Just pass the node to the DOMDocument::saveHTML method:

    $htmlString = $dom->saveHTML($xpath_resultset->item(0));
    

    This will give you a string representation of that particular DOMNode and all its children.

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