Created
May 11, 2017 18:24
-
-
Save viniciuscenci/8cc003a301cf0fddbd4ac2e936be3c95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$html = '<ul> | |
<li><a href=""><img src="http://..."></a></li> | |
<li><a href=""><img src="http://..."></a></li> | |
<li><img src="http://..."></li> | |
<li><a href=""><img src="http://..."></a></li> | |
</ul>'; | |
$dom = new DomDocument(); | |
$dom->loadHTML($html); | |
$xpath = new DOMXPath($dom); | |
foreach($xpath->query('//li') as $li) | |
{ | |
foreach($li->childNodes as $item) | |
{ | |
var_dump($dom->saveHTML($item)); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment