Jump to content

How to do a str_replace to a content:encoded from an RSS Feed


man-chop

Recommended Posts

<?php

// rss page -

$feed_url = "http://blog.kyleramirez.com/feed/";

 

// Load XML.

$xml = simplexml_load_file($feed_url);

 

// How many items to display from the RSS Feed ...

$count = 3;

 

// Grabbing the NameSpace URI for "itms" and "content" ...

foreach ($xml->channel->item as $item) {

$ns_content = $item->children('http://purl.org/rss/1.0/modules/content/');

if($count > 0){

echo "

<ul class=\"pageitem\">

<li class=\"textbox\"><span class=\"header\">{$item->title}</span>

{$ns_content->encoded}

</li>

<li class=\"menu\">

<span class=\"name\"><a href='{$item->link}'>View</a></span></li></ul>

";

}else{

Return;

}

$count--;

}

?>

 

Above is a snippet of code used to extract the content:encoded and title from my RSS feed. I am looking for a way to strip the content part of a few tags, namely style and size and width tags so that I can fit it into the mobile section of my website. The mobile site is m.kyleramirez.com. You will be able to see how the rss feed is implemented there. This shouldn't be that complicated. I was trying to the str_replace to do it but I'm not sure how to put it in there. Any ideas? {$ns_content->encoded} is where the entire post is showing up. How do I add a str_replace to that?

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.