I've trouble with showing RSS news.

However , exactly the same code running in another hosting shows RSS news during this reluctant.

A PHP Error was experienced

Severity: Warning

Message: SimpleXMLElement::__construct(http://www.naslovi.internet/rss/slobodno/) [simplexmlelement.--construct]: unsuccessful to spread out stream: HTTP request unsuccessful! HTTP/1. 403 Forbidden

Filename: sights/index.php

Line Number: 4

My code is

$rss = new SimpleXMLElement('http://www.naslovi.internet/rss/slobodno/', null, true)

foreach($rss->xpath('channel/item') as $item)
{
  $result = $item->xpath('content:encoded');
  preg_match('/<img[^>]+>/', $result[0], $match);
  $item->image = $match[0];
  echo <<<EOF
    <div class="post_heading"><h4><a href='{$item->link}'>{$item->title}</a></h4></div>
    <div>{$item->description} {$item->image}</br></div>

    <div style='font-size:9px;'></br>Objavljeno: {$item->pubDate}</div>
    <hr> EOF;
} ?>

I attempt using CURL and Scraping content however

exactly the same code running in another hosting shows RSS news

According to what's being proven here, it may sound like this other host has permission to gain access to the server resource recommended within the code:

http://www.naslovi.net/rss/slobodno/

Whereas your present host doesn't. The mistake pretty clearly states this:

HTTP/1. 403 Forbidden

The code is working all right. It's effectively implementing towards the Feed. However the server which hosts that feed is denying it access. Your best choice would be to contact the administrator of this server (www.naslovi.net) and discuss it.

It is possible that the host must be put into a whitelist of permitted sites. Or you need to request it in different ways. It's equally entirely possible that they just do not would like you scraping their content.