file_get_html检索p的innertext但不从class中检索

时间:2015-07-08 17:59:43

标签: php html

<div itemprop="commentText" class='post entry-content '>
  <blockquote  class="ipsBlockquote" data-author="B.A" data-cid="53143" data-time="1436336618">
    <div>
      <p>Text that I dont want</p>
    </div>
  </blockquote>
  <p>Text that I want!</p>
  <p>Text that I want!</p>
  <blockquote  class="ipsBlockquote" data-author="Mayor" data-cid="53141" data-time="1436336888">
    <div>
      <p>Text that I dont want</p>
      <p>Text that I dont want!&nbsp;</p>
      <p>Text that I dont want!&nbsp;</p>
    </div>
  </blockquote>
  <p>&nbsp;</p>
  <p>Text to retrieve</p>
</div>

如何检索不属于<p>代码的<blockquote class="ipsBlockquote" ...>代码中的文字?

foreach($html->find('div[itemprop=commentText]') as $element) {
   foreach($element->find('p [!ipsBlockquote]') as $element2) {
       echo $element2->innertext;
   }
}

这就是我所拥有的。它仍然会检索我不想要的文本。

0 个答案:

没有答案