douzhanhui5662 2011-05-09 09:39
浏览 260
已采纳

如何从PHP中的字符串中获取html标签?

I have a html output I'm pulling from a RSS feed, it is somethig like this:

<div>
    <p>
        Some text
    </p>
    <iframe src="http://www.source.com"></iframe>
</div>

The problem is that I only need the attr "src" of the iframe tag, Is there a way to get it with PHP? Regex maybe?

Thanks in advance!

  • 写回答

4条回答 默认 最新

  • dongtao1262 2011-05-09 09:44
    关注

    I'd recommend DOMDocument or SimpleXML.

    Something like this might give you the idea.

    var_dump(simplexml_load_string($rss_feed));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部