Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8290795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:54:57+00:00 2026-06-08T12:54:57+00:00

I have an XML feed that i could fetch news about cyprus on a

  • 0

I have an XML feed that i could fetch news about cyprus on a news site.
I want to use news images and of course news itself.

Here is a sample of xml

 <item>
      <title>Rumlardan KKTC üniversitelerine ambargo</title>
      <description>
        <![CDATA[<p><a href="http://www.ntvmsnbc.com/id/25368624/">
          <img align="left" border="0" src="http://media.ntvmsnbc.com/j/NTVMSNBC/Components/ArtAndPhoto-Fronts/Sections-StoryLevel/Dünya/Kıbrıs/120723girne.thumb.jpg" alt="" style="margin:0 5px 5px 0" /></a> 
          Kıbrıs Rum yönetimi, KKTC'deki üniversitelerle işbirliği yapan ülkelerin eğitim kurumlarına resmi yazılar göndererek yetkilileri tehdit ediyor. Hindistan üniversitesinden ortak akademik programlara son verilmesi istendi.</p><br clear="all" />]]>
      </description>
      <link>http://www.ntvmsnbc.com/id/25368624/</link>
      <media:content medium="image" url="http://media.ntvmsnbc.com/j/NTVMSNBC/Components/ArtAndPhoto-Fronts/Sections-StoryLevel/Dünya/Kıbrıs/120723girne.thumb.jpg">
        <media:text>
          <![CDATA[<p><a href="http://www.ntvmsnbc.com/id/25368624/">
            <img align="left" border="0" src="http://media.ntvmsnbc.com/j/NTVMSNBC/Components/ArtAndPhoto-Fronts/Sections-StoryLevel/Dünya/Kıbrıs/120723girne.thumb.jpg" alt="" style="margin:0 5px 5px 0" />
            </a>
            </p>
            <br clear="all" />]]>
        </media:text>
      </media:content>
      <pubDate>Mon, 23 Jul 2012 14:27:32 GMT</pubDate>
      <category>Haberler</category>
      <guid isPermaLink="true">http://www.ntvmsnbc.com/id/25368624/</guid>
    </item>

The link of the xml is : http://www.ntvmsnbc.com/id/24928068/device/rss/rss.xml

Now i parse this xml with simpleXML with using below code. On this code i could prevent to display <img> tag with strip_ tags i could only display text data in CDATA.

In short what i am asking is how can i get media:content url="" into my code as I want to change thumb.jpg to hlarge.jpg in that url .

I tried $d['media'] = $news->media->attributes(); '<p>'.$post['media']['url']. but it’s not working

Here is my code :

<? 
$NewsFeedUrl =  "http://www.ntvmsnbc.com/id/24928068/device/rss/rss.xml";

$xml = @simplexml_load_file($NewsFeedUrl);

if(is_object($xml)){
    //Rest of our code will be here
}else{
    die('Güncel Haberlere Bağlanılamıyor.');
}

foreach($xml->channel->item as $news){
    if(is_array($newsContent) && count($newsContent)==$amountToShow){
    }
    $description = $news->description;
    $d['title'] =$news->title;
    $d['link'] = $news->link;
    $d['media'] = $news->media->attributes();
    $d['cont'] = $news->description;
    $d['date'] = $news->pubDate;
    $newsContent[]=$d;
}
//$ad=array("thumb", "left");

if(is_array($newsContent)){
    foreach($newsContent as $post){

        echo '

      <article class="entry"><h3>'.'<a href="'.$post['link'].' "target="_blank">'.$post['title'].'</a></h3>
      '.'<div class="meta"><span class="date_post">'.$post['date'].'</span>'.$post['pubDate'].
      //'<p>'.str_replace($ad,"hlarge",$post['cont']).
      '<p>'.$post['cont'].
      '<p>'.strip_tags($post['cont']).
      //'<p>'.$post['media']['url'].
      '<p><a href="'.$post['link'].' "target="_blank" class="button">Devamını Oku</a>'.
      ' </article>';
    }
}else{
    echo '<p>Güncel Haberler Alınamadı Sayfayı Yenilemeyi Deneyin.</p>';
}

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:54:58+00:00Added an answer on June 8, 2026 at 12:54 pm

    The content element has a namespace prefix (<media:content>), so it can’t be accessed by the usual means.

    Namespace-URI for “media” is from http://search.yahoo.com/mrss/ (check your rss.xml for “xmlns:media”).

    Try this:

    foreach ($xml->channel->item as $news)
    {
        $ns_media = $news->children('http://search.yahoo.com/mrss/');
    
        echo $ns_media->content; // displays "<media:content>"
    }
    

    EDIT :

    I think there is some prob with the namespace uri “http://search.yahoo.com/mrss/“

    I tried using your xml :

    http://codepad.org/P90bOQUj [not working]

    I tried using other xml :

    http://codepad.org/ADYveL6T [working]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML feed that I've retrieved via httpwebrequest, and I'm having problems
I have XML in the following form that I want to parse with PHP
Question We have a large number of xml configuration files that we want merged
I have an application that reads an rss feed, parses the xml and adds
I have an XML feed that looks something like this: I can parse the
Have a WCF service (hosted in IIS 6.0) that takes an XML feed from
I have an XML feed that I have transformed into HTML for a dynamic
I have an external xml feed that is pretty poorly structured so Im not
Basically I have an xml feed from an offsite server. The xml feed has
I have a NSString which is passed from an xml feed........ NSString *strDate =@May

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.