0

Im returning xml information from a Newspaper feed.

   //FeedURLs
     $feeds=array("https://larepublica.pe/rss/sociedad.xml?outputType=rss");

 //Read each feed's items
 $entries=array();

 foreach($feeds as $feed){
     $xml=simplexml_load_file($feed);
    $entries=array_merge($entries,$xml->xpath("//item"));

     }

PRINTING

 foreach($entries as $entry){

     echo trim($entry->description)."<br/>";
  }

$entry->description returns this (literally)

 <![CDATA[  ]]>

I tried this with no success

  //$entries = array_map($entries, (array) $xml->xpath("//item"));

What am doing wrong?

This code works for some other feed pages, but in this case It returns empty description.

morty
  • 17
  • 5
  • 1
    if you don't show the actual XML, there's no way for us to tell whether this is working exactly the way it's supposed to or not. Grab that RSS xml, _put it in a file_, and then form your [mcve] with that. – Mike 'Pomax' Kamermans May 25 '20 at 00:23
  • the xml is the lfeed link provided within the code `https://larepublica.pe/rss/sociedad.xml?outputType=rss` – morty May 25 '20 at 00:39
  • 1
    Yes, and that'll do for you, but is _not_ sufficient when posting a question here, because URLs expire. Download that RSS XML, put it in a file, remove all the bits that get parsed fine, and then modify your code to read that file: if things still go wrong, now you have a good [mcve] to put in your post. If things _don't_ go wrong, then you need to have a think about what might actually be going wrong yourself, first (because that's part of the debug process) – Mike 'Pomax' Kamermans May 25 '20 at 00:40
  • Please remember that this is not a general help forum, there are rules on [what can be asked here](/help/on-topic) _and_ there are rules on [how to post a good question](/help/how-to-ask). If you are unwilling to follow those, please delete your post and simply find another place to ask questions. If not, calling people names when they ask you to do what SO policy expects from you is a good way to get your account suspended. We don't ask you do things for our personal benefit, but so that _your question_ becomes a better question, and so that _you_ understand your own problem better. – Mike 'Pomax' Kamermans May 25 '20 at 00:44

0 Answers0