我有一个我试图解析的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。
答案 0 :(得分:1)
试试这个,
foreach($html->find('div#doc-original-text') as $div) {
echo $div->innertext;
}