php xpath我怎样才能得到这个内容

时间:2014-07-27 12:39:19

标签: php xpath

嗨,我真的需要一些帮助。我对Xpath这个概念很陌生,但是我正在考虑它。

但是我遇到了以下代码,我试图获得文章的正文,所以在第一个例子中这将是

  

“法院关闭了180万英镑碳信用额投资公司。    ...... 破产服务人员强迫他们进行清算   过度销售碳信用额销售额。 ...

以及第一个例子中的日期也是

  

“作者Michelle Abrego | 2014年7月14日”

     

我可以使用:

来获得标题
  $website_row = $website_xpath->query('//div[@id="ctl00_ctl00_mainContentPlaceHolder_mtrResults"]//h3[@class="headline"]/a[@id]');
if($website_row->length > 0){

  foreach($website_row as $row){

      echo $row->nodeValue . "<br/><br/>";
      $newTitle = $row->nodeValue;
      $dataStoreForTable['title'][]=$newTitle;

  }

}

但我似乎无法到达身体或日期。

    <div class="columnOne">

  <div id="ctl00_ctl00_mainContentPlaceHolder_mtrResults">
    <p>
      <span id="ctl00_ctl00_mainContentPlaceHolder_mlblResultCount">Results 1 - 10 of about 57 for 'Carbon Credit Fraud' sorted by date - </span>
      <a id="ctl00_ctl00_mainContentPlaceHolder_mlnkChangeSort" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ctl00$mainContentPlaceHolder$mlnkChangeSort&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))">sort by relevance</a>
    </p>




        <h3 class="headline">
          <span id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResults_ctl00_lblNumber">1</span>.
          <a id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResults_ctl00_hlResult" href="/new-model-adviser/court-shuts-down-1-8m-carbon-credit-investment-firms/a761553">Court shuts down £1.8m carbon credit investment firms </a>
        </h3>
        <p id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResults_ctl00_CreditParagraph" class="meta">By Michelle Abrego | 14 Jul 2014</p>
        <p>
          <span id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResults_ctl00_lblSnippet">Court shuts down £1.8m <b>carbon credit</b> investment firms. <b>...</b> The Insolvency Services<br> forced them into liquidation over selling <b>carbon credit</b> sales. <b>...</b>  </span>
        </p>

        <h3 class="headline">
          <span id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResults_ctl01_lblNumber">2</span>.
          <a id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResults_ctl01_hlResult" href="/new-model-adviser/courtroom-clashes-the-biggest-financial-battles-of-the-year-so-far/a757660">Courtroom clashes: the biggest financial battles of the year so far</a>
        </h3>
        <p id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResults_ctl01_CreditParagraph" class="meta">By Jun Merrett | 18 Jun 2014</p>
        <p>
          <span id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResults_ctl01_lblSnippet"><b>...</b> than three years in jail after being found guilty of a £1.6 million <b>fraud</b>. <b>...</b> The court<br> had heard that Ames led investors into bogus <b>carbon credit</b> and teak tree <b>...</b>  </span>
        </p>

        <ul class="pagination">
          <li class="previous"></li>

          <li id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResultsPager_ctl01_lnkPageLi" class="active">1</li>

          <li id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResultsPager_ctl02_lnkPageLi"><a id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResultsPager_ctl02_lnkPage" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ctl00$mainContentPlaceHolder$mrpAllSearchResultsPager$ctl02$lnkPage&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))">2</a></li>

          <li id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResultsPager_ctl03_lnkPageLi"><a id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResultsPager_ctl03_lnkPage" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ctl00$mainContentPlaceHolder$mrpAllSearchResultsPager$ctl03$lnkPage&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))">3</a></li>

          <li id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResultsPager_ctl04_lnkPageLi"><a id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResultsPager_ctl04_lnkPage" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ctl00$mainContentPlaceHolder$mrpAllSearchResultsPager$ctl04$lnkPage&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))">4</a></li>

          <li id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResultsPager_ctl05_lnkPageLi"><a id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResultsPager_ctl05_lnkPage" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ctl00$mainContentPlaceHolder$mrpAllSearchResultsPager$ctl05$lnkPage&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))">5</a></li>

          <li id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResultsPager_ctl06_lnkPageLi"><a id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResultsPager_ctl06_lnkPage" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ctl00$mainContentPlaceHolder$mrpAllSearchResultsPager$ctl06$lnkPage&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))">6</a></li>

          <li class="next"><a id="ctl00_ctl00_mainContentPlaceHolder_mrpAllSearchResultsPager_ctl07_lnkPage" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ctl00$mainContentPlaceHolder$mrpAllSearchResultsPager$ctl07$lnkPage&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))">Next</a></li>
        </ul>

  </div>

</div>

0 个答案:

没有答案