This project has moved. For the latest updates, please go here.

HELP REQUEST: Modify Returned RSS Items

Topics: Developer Forum, User Forum
Jun 24, 2007 at 4:01 PM
Edited Jun 24, 2007 at 4:05 PM
Hi everyone,

I'm pretty new to this control and accessing data components, so I appreciate your help and patience with this problem. If it's already been asked and answered please point me in the right direction. I've got a couple of item manipulation challenges...

I am able to return an RSS feed with the RSSDataSource. What I want to be able to do is modify the contents of the returned items. For example, if a particular news article is coming in from CNN, I want to be able to modify the title, pub date, or description that is outputted to add attribution to CNN (CNN - Newstory Headline Here).

Likewise, some feeds are incorporating HTML for images in their descriptions. While I wouldn't mind having the images in the descriptions, the layout doesn't work for my site. I need to be able to parse the image code out of the description, store it, and move it around or modify its size and position to work within my layout (or just get rid of it entirely). Here's an example of a returned description that has image code:

Note: The feed has everything encoded with & codes, to see what it actually looks like, view the source of this post.

<description>
<p><a rel="nofollow" target="blank" href="http://us.rd.yahoo.com/dailynews/rss/politics/*http://news.yahoo.com/s/ap/20070624/apongoco/congressimmigration"><img src="http://d.yimg.com/us.yimg.com/p/ap/20070621/capt.848bf2738c30493eaca5aa46ba151881.immigrationwcap101.jpg?x=130&y=88&sig=X0mP09ZASyBufijOvG4LSA--" align="left" height="88" width="130" alt="Senator Edward Kennedy discusses immigration reform legislation during a news conference in Washington Thursday, June 21, 2007. Senator Dianne Feinstein, D-Calif., is at right. (AP Photo/Dennis Cook)" border="0"/></a>AP - Senators pushing a new immigration policy appealed Sunday to wavering supporters ahead of renewed debate on securing the borders and dealing with 12 million undocumented immigrants.</p><br clear="all"/>
</description>

I probably need some sort of RegEx (I really don't know much about them) to pull out this image.

Also, some feeds have advertisements in them. I really want to strip out all <items> that contain an ad. Any thoughts on how to do this? I don't want to violate any terms by removing the ad... I just want the entire <item> removed. I could build a function to handle this I'm sure I just don't know how to go about parsing the items and doing the search.

Thanks a lot in advance for your help on these issues!!

Greg