parsing - Get Attribute Value PHP -
this source code getting remote source
<div class=hello> <a class="abc" href="http://www.example.com" a1="page1" a2="wel-come" data-image="example.com/1.jpeg"> <div>you here</div> . . . <a class="abc" href="http://www.example.com" a1="page2" a2="aboutus" data-image="example.com/2.jpeg"> </div>
i using php dom parser parsing html need output
page1 http://www.example.com <img src="example.com/1.jpeg"> page2 http://www.example.com <img src="example.com/2.jpeg">
foreach($html->find('a') $element) { echo $element->a1; echo $element->image; echo "<img src='" . $element->image . "'/>"; }
should work?
if direct access ->a1 , ->image not work, attempt:
$element->getattribute('a1') $element->getattribute('image')
edit: lib referring to, correct? http://simplehtmldom.sourceforge.net/manual.htm
Comments
Post a Comment