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

落爺英雄遲暮 提交于 2021-02-20 04:14:07

问题


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?


回答1:


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']


来源:https://stackoverflow.com/questions/44561418/how-can-i-extract-the-image-path-from-riattachment-rifilename-stories-img-05

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!