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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.