Parsing RSS / RegEx n00b

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I must confess that I'm behind the curve on my regular expression syntax. I
am trying to just take an RSS feed and parse the info I want from it using
preg_match_all() (I know there are more proper ways and even PEAR libraries
to this, but I just need to keep things simple. So far it's working great
when I do the following:
preg_match_all("/(<title>)(.*)(<\/title>)/", $rss, $titles, PREG_SET_ORDER);

The problem comes up with one of the tags I want to parse called
'<content:encoded>'. It seems the colon is throwing everything off, and I've
poked around google for regex info trying to make this work, but no luck. I
know this must be something simple I just don't understand about regex...

Can anyone help me with this? For bonus points, how would I then parse out
the image tags from the <content:encoded> section of the feed? Being that
img tags don't use closing tags in html. My end goal is to get the image
html code from this data.


Re: Parsing RSS / RegEx n00b

Adam Gaskins wrote:
Quoted text here. Click to load it

Parsing XML isn't a simple task.  I wouldn't even try to use regular
expressions.  Rather, I'd use either the DOM or SimpleXML functions.
Much easier and more flexible.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: Parsing RSS / RegEx n00b

Thanks Jerry. It is working fine for now, and I'm just trying to get a site
mock up before a deadline. Is there a way to just parse out those
content:encoded tags like I can with all the rest? There has to be some
little thing I'm missing about the regex to make it work with that colon.

I do agree with you though, having glanced at those functions I will figure
out a more proper way to do this for the production site.



Quoted text here. Click to load it

Site Timeline