我想在使用简单 HTML dom 解析器解析期间打印内部文本
HTML 源代码:
<div id="ctl00_ContentPlaceHolder_Middle_RatingSummary1_Rating1_RatingPanel">
<img id="ctl00_ContentPlaceHolder_Middle_RatingSummary1_Rating1_RatingImage" title="(2.5 / 5) : Above Average" src="../../../../../images/net/common/stars/transparent/2.5.png" alt="(2.5 / 5) : Above Average" style="border-width:0px;" />
<span id="ctl00_ContentPlaceHolder_Middle_RatingSummary1_Rating1_RatingText" class="text med strong">(2.5 / 5) : Above Average</span>
<a id="ctl00_ContentPlaceHolder_Middle_RatingSummary1_Rating1_RatingHelp" class="help"></a>
我想要这样的输出:
(2.5 / 5) : Above Average
我试过了,但没有得到它:
php代码:
$ratings = $html->find('div[id=ctl00_ContentPlaceHolder_Middle_RatingSummary1_Rating1_RatingPanel] span')->outertext;
echo "$ratings[0]";