Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.lang.php Subject: Re: view rss item content Date: Tue, 25 Jul 2017 18:31:35 +0200 Lines: 60 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: individual.net pG5UG1uRWHeg6f2I+rSGowX3B+mkxunmkBTu8A+fbvFFYlJDLI Cancel-Lock: sha1:PkW5ifLEhKEu5PRlejzkER0EG0k= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 In-Reply-To: Content-Language: en-GB Xref: csiph.com comp.lang.php:17553 On 07/25/17 09:19, alex wrote: > > $extended_format=true;// turn on extended view > > // first item getting > $_ = > simplexml_load_file('http://feeds.bbci.co.uk/news/rss.xml?edition=uk')-> > channel-> > item[0] > ; > > echo > "

" . $_->title .' - ' . $_->link . "

\n", > $extended_format ? > $_->children( > "content", > true > ) : > $_->description > ; > > ?> > > > > $ php test.php > >

Charlie Gard: 'Last precious moments' for parents with their son - > http://www.bbc.co.uk/news/uk-england-london-40712913

> > Because "content" is missing? Did you look at the xml? <![CDATA[Parents plea to take Charlie home]]> http://www.bbc.co.uk/news/uk-england-london-40716292 http://www.bbc.co.uk/news/uk-england-london-40716292 Tue, 25 Jul 2017 13:58:55 GMT There ain't any content, also there ain't multiple instances of the same "name" in the item object, so no need to use the children() function. I suggest you also switch the name of the variable, as it will be a lot easier on you when you come back to old code. Keep in mind that the code is run on the server side, so short variable names will not mean less data is sent to the user. -- //Aho