How to get <li> inner html using php DOM method -
how <li> inner html using php dom method these in php string variable ihave filter li inner html
<div class="cmodule myphotos"> <h3><span>my photos</span></h3> <ul class="cresetlist cthumblist clrfix"> <li> <a href="/projects/mysportsjam/index.php/joom-social/103-shine/photos/photo?albumid=12#photoid=67" hidefocus="true" style="outline: none;"><img class="cavatar jomnametips cavatar-sidebar" title="uploaded shine s" src="http://107.20.167.165/projects/mysportsjam/images/photos/103/12/thumb_05c0beeb8f0f32a08538dad7.jpg" alt="shine s"></a> </li> <li> <a href="/projects/mysportsjam/index.php/joom-social/103-shine/photos/photo?albumid=12#photoid=43" hidefocus="true" style="outline: none;"><img class="cavatar jomnametips cavatar-sidebar" src="http://107.20.167.165/projects/mysportsjam/images/photos/103/12/thumb_c122ff8dafd2edeba377a1cd.jpg" alt="shine s" original-title="uploaded shine s"></a> </li> <li> <a href="/projects/mysportsjam/index.php/joom-social/103-shine/photos/photo?albumid=12#photoid=66" hidefocus="true" style="outline: none;"><img class="cavatar jomnametips cavatar-sidebar" title="uploaded shine s" src="http://107.20.167.165/projects/mysportsjam/images/photos/103/12/thumb_9414b5dff6c8644d197ff684.jpg" alt="shine s"></a> </li> </ul> <div class="app-box-footer"> <a href="/projects/mysportsjam/index.php/joom-social/103-shine/photos" hidefocus="true" style="outline: none;">view photos</a> </div> </div> how filter li inner html href link , image tag.
you can use domdocument that.
the sample code shows how href attribute. think can figure out how image's src.
<?php $xml = new domdocument(); $xml->loadhtml($body); $nodes = $xml->getelementsbytagname('li'); for($curr = 0; $curr < $nodes->length; $curr++) { $li = $nodes->item($curr); $innerhtml= ''; $children = $li->childnodes; foreach ($children $child) { $innerhtml .= $child->ownerdocument->savexml( $child ); } print $innerhtml; foreach($li->childnodes $child) { $a = $child; if(is_a($a, "domelement")) { $href = $a->getattribute('href'); print "{$href}\n"; } } print "\n"; }
Comments
Post a Comment