Jump to content

Using regex on an rss feed?


JMusic

Recommended Posts

I am trying to create one "master" feed that includes data from all of the sites in my network, and I am using regex to copy all of the content into a new database. I have been able to copy the titles and links without any problem, but I'm running into trouble when trying to copy the content within the description, which is set up like this:

 

<description>

<![CDATA[

Some text here with <b>some</b> <I>HTML</i> elements, [...]

]]>

</description>

 

I tried using the following to just extract the content within CDATA:

 

preg_match_all("/CDATA\[([^(?!\]\]\>)]*)/is",$data,$match);

 

But instead of stopping at the string "]]>" like I want it to, it's stopping at the first instance of "]" (I want it to stop at the entire "]]>" phrase). So my question is:

 

Is there a better regex to just get the description?

 

AND

 

Is there a way to include any characters up to a certain phrase, or can you only do it on an individual character basis like the string above?

 

Link to comment
https://forums.phpfreaks.com/topic/45009-using-regex-on-an-rss-feed/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.