Solved

RSS Feed Enclosure URL

Posted on 2016-09-08
1
229 Views
Last Modified: 2016-09-10
I'm trying to grab just the url from the enclosure tag

<rss version="2.0">
<channel>
<title>
<![CDATA[ Queryfeed | #golf,from:nrileykc ]]>
</title>
<ttl>10</ttl>
<description>
Queryfeed searches in Twitter, Google+ and gives you a nice RSS. Enjoy!
</description>
<generator>queryfeed.net</generator>
<webmaster>admin@queryfeed.net</webmaster>
<item>
<link>
http://twitter.com/twitter/status/773970114764869632
</link>
<guid>
http://twitter.com/twitter/status/773970114764869632
</guid>
<title>
<![CDATA[ Nathan Riley @nrileykc ]]>
</title>
<author>nrileykc</author>
<enclosure url="http://pbs.twimg.com/media/Cr2xto1UkAA56xV.jpg" type="image/jpeg"/>
<category>golf</category>
<pubDate>Thu, 08 Sep 2016 19:43:49 +0000</pubDate>
<description>
<![CDATA[
<a href="https://twitter.com/hashtag/golf">#golf</a> test https://t.co/7SBUt9cd0A
]]>
</description>
</item>
<item>
<link>
http://twitter.com/twitter/status/773954372262699008
</link>
<guid>
http://twitter.com/twitter/status/773954372262699008
</guid>
<title>
<![CDATA[ Nathan Riley @nrileykc ]]>
</title>
<author>nrileykc</author>
<category>golf</category>
<pubDate>Thu, 08 Sep 2016 18:41:16 +0000</pubDate>
<description>
<![CDATA[
test <a href="https://twitter.com/hashtag/golf">#golf</a>
]]>
</description>
</item>
</channel>
</rss>

Open in new window

0
Comment
Question by:Nathan Riley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 41790305
See if this gets what you want: https://iconoun.com/demo/temp_nr.php
<?php // demo/temp_mr.php
/**
 * https://www.experts-exchange.com/questions/28968617/RSS-Feed-Enclosure-URL.html
 *
 * http://php.net/manual/en/ref.simplexml.php
 * http://php.net/manual/en/class.simplexmlelement.php
 */
ini_set('display_errors', TRUE);
error_reporting(E_ALL);
echo '<pre>';


// TEST DATA FROM THE POST AT E-E
$xml = <<<EOX
<rss version="2.0">
<channel>
<title>
<![CDATA[ Queryfeed | #golf,from:nrileykc ]]>
</title>
<ttl>10</ttl>
<description>
Queryfeed searches in Twitter, Google+ and gives you a nice RSS. Enjoy!
</description>
<generator>queryfeed.net</generator>
<webmaster>admin@queryfeed.net</webmaster>
<item>
<link>
http://twitter.com/twitter/status/773970114764869632
</link>
<guid>
http://twitter.com/twitter/status/773970114764869632
</guid>
<title>
<![CDATA[ Nathan Riley @nrileykc ]]>
</title>
<author>nrileykc</author>
<enclosure url="http://pbs.twimg.com/media/Cr2xto1UkAA56xV.jpg" type="image/jpeg"/>
<category>golf</category>
<pubDate>Thu, 08 Sep 2016 19:43:49 +0000</pubDate>
<description>
<![CDATA[
<a href="https://twitter.com/hashtag/golf">#golf</a> test https://t.co/7SBUt9cd0A
]]>
</description>
</item>
<item>
<link>
http://twitter.com/twitter/status/773954372262699008
</link>
<guid>
http://twitter.com/twitter/status/773954372262699008
</guid>
<title>
<![CDATA[ Nathan Riley @nrileykc ]]>
</title>
<author>nrileykc</author>
<category>golf</category>
<pubDate>Thu, 08 Sep 2016 18:41:16 +0000</pubDate>
<description>
<![CDATA[
test <a href="https://twitter.com/hashtag/golf">#golf</a>
]]>
</description>
</item>
</channel>
</rss>
EOX;


// MAKE AN OBJECT AND FIND THE URL IN THE ENCLOSURE TAG
$obj = SimpleXML_Load_String($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
$url = (string)$obj->channel->item[0]->enclosure->attributes()->url;
var_dump($url);

Open in new window

Outputs:
string(46) "http://pbs.twimg.com/media/Cr2xto1UkAA56xV.jpg"

Open in new window

0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

634 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question