2016-03-29 20 views
0

こんにちは私はliの内容を抽出するために以下を使用していますが、すべて正常に機能しますが、タグとテキストも含めたいと思います。私は "$ element2-> plaintext"の代わりに何を書く必要がありますか?ここ タグとテキストの抽出PHPシンプルなHTML DOMパーサーマニュアル

// Create DOM from URL or file 
    $html = file_get_html('2002-10-01.html'); 

    // Find all images 
    foreach($html->find('table tr[bgcolor=#FFCCCC]') as $element) { 
      foreach($element->find('li') as $element2) { 

///just plain text 
      echo $element2->plaintext . '<br>'; 

///plain text and html elements 

echo $element2->html. '<br>'; 

      } 

      } 

は私が

<tr bgcolor="#FFCCCC"> <!-- HEADLINE TEXT --> 
         <td class="blue_body"> 
         <ul> 
          <li><font size="2" face="Arial, Helvetica, sans-serif" color="#000000">As 
          <b>Bertelsmann</b> continues to haggle with Clive 
          Calder over how much it must pay to buy his Zomba 
          independent record company, it plans to consolidate 
          <b>Zomba</b> under its RCA label. <a href="http://www.nypost.com/business/58425.htm">NYPost</a> 
          </font> 
          <li><font size="2" face="Arial, Helvetica, sans-serif" color="#000000">News 
          Corporation and Telecom Italia are expected to announce 
          a deal today to acquire the Italian satellite television 
          operation of <b>Vivendi Universal</b> for $464m in 
          cash. <a href="http://www.nytimes.com/2002/10/01/business/media/01RUPE.html">NYTimes</a> 
          </font> 
          <li><font size="2" face="Arial, Helvetica, sans-serif" color="#000000">Two 
          years after <b>America Online</b> agreed to acquire 
          Time Warner, Ted Turner has soured on both the merger 
          and Stephen Case, its principal architect. <a href="http://nytimes.com/2002/10/01/technology/01AOL.html">NYTimes</a> 
          </font> 
         </ul> 
         </td> 
        </tr> 

答えて

0

が答えを見つけて抽出していますhtmlです

echo $element2->outertext . '<br>'; 
関連する問題