Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
提取标签以及文本PHP简单HTML DOM解析器手册_Php_Parsing - Fatal编程技术网

提取标签以及文本PHP简单HTML DOM解析器手册

提取标签以及文本PHP简单HTML DOM解析器手册,php,parsing,Php,Parsing,嗨,我使用以下内容来提取李的内容,一切都很好,但我也想包括和标签以及文本。我需要写什么来代替“$element2->明文” //从URL或文件创建DOM $html=file_get_html('2002-10-01.html'); //查找所有图像 foreach($html->find('table tr[bgcolor=#FFCCCC]')作为$element){ foreach($element->find('li')作为$element2){ ///纯文本 echo$element2-

嗨,我使用以下内容来提取李的内容,一切都很好,但我也想包括和标签以及文本。我需要写什么来代替“$element2->明文”

//从URL或文件创建DOM
$html=file_get_html('2002-10-01.html');
//查找所有图像
foreach($html->find('table tr[bgcolor=#FFCCCC]')作为$element){
foreach($element->find('li')作为$element2){
///纯文本
echo$element2->纯文本。“
”; ///纯文本和html元素 echo$element2->html。“
”; } }
这是我正在提取的html

<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>

  • 作为 贝塔斯曼继续与克莱夫讨价还价 考尔德为买他的Zomba必须支付多少钱 独立唱片公司,计划合并 在其RCA标签下的Zomba。
  • 新闻 公司和意大利电信预计将宣布 今天达成了收购意大利卫星电视台的协议 Vivendi Universal的运营费用为4.64亿美元 现金。
  • 两个 在美国在线同意收购 时代华纳、泰德·特纳对这两家公司的合并都感到不满 以及它的首席设计师斯蒂芬·凯斯。
找到了答案

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