我有一个要解析的 HTML 文件。它有一堆像这样的DIV:
<div class="doc-overview">
<h2>Description</h2>
<div id="doc-description-container" class="" style="max-height: 605px;">
<div class="doc-description toggle-overflow-contents" data-collapsed-height="200">
<div id="doc-original-text">
Content of the div without paragraph tags.
<p>Content from the first paragraph </p>
<p>Content from the second paragraph</p>
<p>Content from the third paragraph</p>
</div>
</div>
<div class="doc-description-overflow"></div>
</div>
我试过这个:
foreach($html->find('div[id=doc-original-text]') as $div) {
echo $div->innertext;
}
您注意到我直接找到了,doc-original-text
但我也尝试从外部 div 解析到内部 div。