Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

RSS Feed Enclosure URL

Posted on 2016-09-08
1
Medium Priority
?
281 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 111

Accepted Solution

by:
Ray Paseur earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

670 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