codecrapht Posted November 11, 2008 Share Posted November 11, 2008 Hello, I have some code that pulls in an RSS feed. The issue is that the 'description' contains CDATA with text, link and images code. I just need to pull out 'parse' the image url and have it avalible in a string variable. I'm not sure what else to say, so please ask if you need more information. Thanks for your time and help! Quote Link to comment https://forums.phpfreaks.com/topic/132315-solved-parsing-a-string-for-url/ Share on other sites More sharing options...
DarkWater Posted November 11, 2008 Share Posted November 11, 2008 Can I see an example description tag? Also, you know how to actually get the data in description with like, SimpleXML, right? Quote Link to comment https://forums.phpfreaks.com/topic/132315-solved-parsing-a-string-for-url/#findComment-687904 Share on other sites More sharing options...
codecrapht Posted November 11, 2008 Author Share Posted November 11, 2008 Here is the item code: <item> <title>Example URL</title> <link>http://www.exampleurl.com/</link> <guid isPermaLink="false">guid_2008-11-11-1876</guid> <description> <![CDATA[ Some sample content is included here.<br><a border="0" href="http://www.exampleurl.com/" target="_blank"><img src="http://www.exampleurl.com/rss_image.jpg"/></a> ]]> </description> <pubDate>Tue, 11 Nov 2008 00:00:00 -0800</pubDate> </item> I’m not familiar with SimpleXML. Will that break out the CDATA? Thank you very much for your help! Quote Link to comment https://forums.phpfreaks.com/topic/132315-solved-parsing-a-string-for-url/#findComment-687967 Share on other sites More sharing options...
premiso Posted November 11, 2008 Share Posted November 11, 2008 http://us.php.net/simplexml A good place to read up on it. Quote Link to comment https://forums.phpfreaks.com/topic/132315-solved-parsing-a-string-for-url/#findComment-687969 Share on other sites More sharing options...
codecrapht Posted November 11, 2008 Author Share Posted November 11, 2008 By “get the data in description with like, SimpleXML” do you mean just showing the text, link and image? Is so then yes, I have the description showing, but I need to just show the image. I have my own descriptions. Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/132315-solved-parsing-a-string-for-url/#findComment-687972 Share on other sites More sharing options...
premiso Posted November 11, 2008 Share Posted November 11, 2008 Let's say you have this string: <![CDATA[ Some sample content is included here.<br><a border="0" href="http://www.exampleurl.com/" target="_blank"><img src="http://www.exampleurl.com/rss_image.jpg"/></a> ]]> If you have that string you can easily get the img url by doing the following: <?php $string = ' <![CDATA[ Some sample content is included here.<br><a border="0" href="http://www.exampleurl.com/" target="_blank"><img src="http://www.exampleurl.com/rss_image.jpg"/></a> ]]>'; $parsed = explode("src=\"", $string); $parsed = explode("\"/>", $parsed[1]); $imageUrl = $parsed[0]; echo $imageUrl; ?> Quote Link to comment https://forums.phpfreaks.com/topic/132315-solved-parsing-a-string-for-url/#findComment-687977 Share on other sites More sharing options...
codecrapht Posted November 12, 2008 Author Share Posted November 12, 2008 Great, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/132315-solved-parsing-a-string-for-url/#findComment-688165 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.