I need to filter and reorder an RSS
feed.
Using PHP
, how would I detect if there is a link in the enclosure url=""
?
Most of these will be empty, but I'd like to move the whole item that has a link in this tag to the top.
Here is an example of the code I'll be working with. I'm guessing I would use isset
? Something like:
if (isset($enclosure)){
HOW WOULD I SELECT THE PARENT ITEM? AND EVERYTHING IN IT? AND THEN MOVE IT TO THE TOP?
}
<item>
<title><![CDATA[Article title 1]]></title>
<link><![CDATA[http://www.articlelinkone.com]]></link>
<pubDate><![CDATA[Tue, 26 Feb 2013 15:45:00 EDT]]></pubDate>
<description><![CDATA[Article discription 1<br />Some HTML will exist]]></description>
<enclosure url="" type="image/jpeg"></enclosure>
<thumbnail url="" type="image/jpeg"></thumbnail>
<summary><![CDATA[Summary for article]]></summary>
<guid><![CDATA[Guide for article]]></guid>
<source url="http://www.article.com/"/>
</item>
<item>
<title><![CDATA[Article title 1]]></title>
<link><![CDATA[http://www.articlelinkone.com]]></link>
<pubDate><![CDATA[Tue, 26 Feb 2013 15:45:00 EDT]]></pubDate>
<description><![CDATA[Article discription 1<br />Some HTML will exist]]></description>
<enclosure url="" type="image/jpeg"></enclosure>
<thumbnail url="" type="image/jpeg"></thumbnail>
<summary><![CDATA[Summary for article]]></summary>
<guid><![CDATA[Guide for article]]></guid>
<source url="http://www.article.com/"/>
</item>
<item>
<title><![CDATA[Article title 1]]></title>
<link><![CDATA[http://www.articlelinkone.com]]></link>
<pubDate><![CDATA[Tue, 26 Feb 2013 15:45:00 EDT]]></pubDate>
<description><![CDATA[Article discription 1<br />Some HTML will exist]]></description>
<enclosure url="http://articleone.com/image1.jpg" type="image/jpeg"></enclosure>
<thumbnail url="http://articleone.com/thumb/image1.jpg" type="image/jpeg"></thumbnail>
<summary><![CDATA[Summary for article]]></summary>
<guid><![CDATA[Guide for article]]></guid>
<source url="http://www.article.com/"/>
</item>
<item>
<title><![CDATA[Article title 1]]></title>
<link><![CDATA[http://www.articlelinkone.com]]></link>
<pubDate><![CDATA[Tue, 26 Feb 2013 15:45:00 EDT]]></pubDate>
<description><![CDATA[Article discription 1<br />Some HTML will exist]]></description>
<enclosure url="" type="image/jpeg"></enclosure>
<thumbnail url="" type="image/jpeg"></thumbnail>
<summary><![CDATA[Summary for article]]></summary>
<guid><![CDATA[Guide for article]]></guid>
<source url="http://www.article.com/"/>
</item>