Search code examples
phpsimple-html-dom

How Can I extract the image path from <ri:attachment ri:filename="stories-img-05.png" />


Here is the original code where I am extracted the data using Simple HTML Dom:

<div class="content-wrapper"><p><ac:image ac:height="250"><ri:attachment ri:filename="stories-img-05.png" /></ac:image></p></div>

Here is the code which i am using :

$html->find('div[class=content-wrapper] p ac:image ', 0)->innertext;

How can I get Image Path?


Solution

  • For multiple use this code:

        $img=array();
        foreach($html->find('div.content-wrapper ri:attachment[ri:filename]') as $article) {
            array_push($img, $article->attr['ri:filename']);
        }
        print_r($img);
    

    For single use this:

    $html->find('div.content-wrapper ri:attachment[ri:filename]')[0]->attr['ri:filename']