Grab img tag from Google Web album's RSS item description

How can I remove everything but the img tag, and it's attributes, from
the html generated by Google Web Album's RSS item description shown
below?

I have the code I am using at present below but I was hoping for a more
reliable alternative.

Cheers,

Chris

// HTML generated by Google
<table>
<tr><td>
<div style="text-align:center;height:194px;">
<a href="http://www.test.com/">
<img style="margin-top:15px;border:1px solid #5C7FB9"
src="http://www.test.com" alt="City001.JPG" border="0"/>
</a>
</div>
</td>
<td valign="top"><p><font color="#333333"></font></p>
<p><font color="#333333"><b>City001.JPG</b></font></p>
<font color="#6B6B6B">Date: </font><font color="#333333">16-Jan-2007
02:38</font>
<br/><font color="#6B6B6B">Number of Comments on Photo: </font>
<font color="#333333">0</font><br/>
<p><a href="http://www.test.com">
<font color="#112ABB"><b>View
Photo</b></font></a>  |  <a
href="http://www.test.com"><font color="#112ABB"><b>View
Feed</b></font></a></p></div></td></tr></table>

// Code I am using at present
foreach ($rss->items as $item) {
$strip_img = strip_tags($item['description'], '<img>');
$explode_string = explode(">", $strip_img);
$img[] .= $explode_string[0].">";
}
Chris Matchett [ Di, 16 Januar 2007 17:39 ] [ ID #1597315 ]

Re: Grab img tag from Google Web album's RSS item description

In article <1168965554.371518.28080 [at] a75g2000cwd.googlegroups.com>,
Chris Matchett <news.chris [at] gmail.com> wrote:

> How can I remove everything but the img tag, and it's attributes, from
> the html generated by Google Web Album's RSS item description shown
> below?
>
> I have the code I am using at present below but I was hoping for a more
> reliable alternative.


The regular expression I am using here is VERY basic, but it's another
alternative:


<?php
$html = file_get_contents( "http://www.ebay.com" );
preg_match_all("/<img[^>]+>/", $html, $matches );
foreach( $matches[0] as $match ){
if(preg_match( '/src="([^"]+)"/', $match, $src, PREG_OFFSET_CAPTURE
)){
echo "Got source image : ", $src[1][0], "\n";
}
}
?>

--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit." -Nietzsche
Koncept [ Mi, 17 Januar 2007 03:09 ] [ ID #1598834 ]
PHP » alt.php » Grab img tag from Google Web album's RSS item description

Vorheriges Thema: how to convert text into mysql date format?
Nächstes Thema: Re: Any Intelligent Thoughts On This?