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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -