php - How to Print innertext during Parsing with Simple HTML dom parser -
i want print innertext during parsing simple html dom parser
html source code:
<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>
i want output this:
(2.5 / 5) : above average
i tried it, not getting it:
php code:
$ratings = $html->find('div[id=ctl00_contentplaceholder_middle_ratingsummary1_rating1_ratingpanel] span')->outertext; echo "$ratings[0]";
check out:
$dom = new domdocument(); $html = $file_get_contents('myfile.html'); @$dom->loadhtml($html); $a = dom->getelementsbytagname('img'); foreach($a $tags) { $attr = $tags->getattribute('title'); echo $attr }
or may try directly based on html input:
$attr = dom->getelementsbytagname('img')->getattribute('title'); echo $attr
Comments
Post a Comment