0

Before I make this question, I've been looking and have found some matches ... Like

How to Parse XML's Media:Content with PHP?

but can not display images, And

get image src from <content:encoded>

but there is no link... I want, Title, Image and URL. How? Can you help me??

This my code:

$html = "";
$url = "https://www.ciusan.com/feed/";
$xml = simplexml_load_file($url);
echo '<div class="row">';
    for($i = 0; $i < 5; $i++){
        $image      = $xml->channel->item[$i]->children('media', True)->content->attributes();
        $title      = $xml->channel->item[$i]->title;
        $link       = $xml->channel->item[$i]->link;
        $description= $xml->channel->item[$i]->description;
        $pubDate    = $xml->channel->item[$i]->pubDate;
        $html .= '<div align="center" class="one-fifth columns">';
            $html .= "<img src='".$image."' alt='".$title."'>";
            $html .= "<a href='$link'><h3>$title</h3></a>";
            // $html .= "$description";
            // $html .= "<br />$pubDate";
        $html .= '</div>';
    }
echo $html;
echo '</div>';

I want to showing feed from other sites in my site, i want showing image, title and link to the title post.. With my code the title and link can showing, but the image not showing with the error Warning: SimpleXMLElement::__toString(): Node no longer exists in C:\dev\www\public_html\01\example.php on line 155

IMSoP
  • 89,526
  • 13
  • 117
  • 169
  • Please can you [edit] your question (don't just add in comments) to include a [mcve] - what is the XML you're processing, what is the desired output, and what is the output you have at the moment? – IMSoP Mar 04 '17 at 21:05
  • In the second link, you can find how to extract CDATA content, and how to parse it. This html part doesn't contain any img tags but a link to an other html file that contains the img tag you are looking for. So you need to find this link, to extract the URL and to parse this html file. Copy/Paste will not help, you need to understand what you are doing. – Casimir et Hippolyte Mar 05 '17 at 13:41

0 Answers0