Using PHP to display RSS feed attributes

老子叫甜甜 提交于 2019-12-12 05:11:06

问题


I am attempting to display results from an RSS feed using PHP. I have successfully used magpie [magpierss.sourceforge.net] and rss_php [rssphp.net]

However, both parsers I am having issues getting the attrbute values specifically media:thumbnail

<media:content url="http://cache.wdcdn.net/cdn/asset/view/client/sfi/package/library/id/692313/format/o/h/5c5b86ff5dc804b2d314b3a9718bdef0/JelloAdultContentDirsCut.m4v?7a6013aef28682d61703dff120d21b12266b54a2a637283d7d4f0a0b41a1f35116ad845809e136636fd6663e34fb341ed348bcd006.m4v" fileSize="5936750" type="video/mp4" duration="32" height="360" width="640"/>

<media:thumbnail url="http://cache.wdcdn.net/cdn/asset/view/client/sfi/package/library/id/692313/format/t/size/lg/h/c374cb3c669fdb346ad82adb16b41b4a/library_692313_lg.jpg?7a6013aef28682d61703dff120d21b12266b54a2a637283d7d4f0a0b41a1f35116ad845809e136636fd6663e34fb341ed348bcd006.jpg" height="360" width="634"/>

<media:thumbnail url="http://cache.wdcdn.net/cdn/asset/view/client/sfi/package/library/id/692313/format/t/size/sm/h/c374cb3c669fdb346ad82adb16b41b4a/library_692313_sm.jpg?7a6013aef28682d61703dff120d21b12266b54a2a637283d7d4f0a0b41a1f35116ad845809e136636fd6663e34fb341ed348bcd006.jpg" height="102" width="180"/>

<media:credit role="client" scheme="urn:feeds-wiredrive-com:credits"><![CDATA[Jell-O]]></media:credit>

<media:credit role="director" scheme="urn:feeds-wiredrive-com:credits"><![CDATA[Jerry Simpson]]></media:credit>

<media:credit role="agency" scheme="urn:feeds-wiredrive-com:credits"><![CDATA[CPB]]></media:credit>

<media:keywords><![CDATA[Chocolate, dessert, fruit, Jell-O, pudding]]></media:keywords></item>

any tips or help? I am stumped.


回答1:


Maybe could you try using one of these prebuilt classes instead ? http://php.net/manual/en/refs.xml.php Give simplexml a shot for instance.




回答2:


My solution was to use simplepie. simplepie.org very good parser and has built in class for exactly this. get_thumbnail() and many other useful classes. recommended



来源:https://stackoverflow.com/questions/10306436/using-php-to-display-rss-feed-attributes

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