Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #17553

Re: view rss item content

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: view rss item content
Date Tue, 25 Jul 2017 18:31:35 +0200
Lines 60
Message-ID <etpa38Fd3ssU1@mid.individual.net> (permalink)
References <ol6re6$14jp$1@gioia.aioe.org>
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 <ol6re6$14jp$1@gioia.aioe.org>
Content-Language en-GB
Xref csiph.com comp.lang.php:17553

Show key headers only | View raw


On 07/25/17 09:19, alex wrote:
> <?php // test.php
> 
> $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
>     "<h3>" . $_->title .' - ' . $_->link . "</h3>\n",
>     $extended_format ?
>         $_->children(
>             "content",
>             true
>         ) :
>         $_->description
> ;
> 
> ?>
> 
> 
> 
> $ php test.php
> 
> <h3>Charlie Gard: 'Last precious moments' for parents with their son -
> http://www.bbc.co.uk/news/uk-england-london-40712913</h3>
> 
> Because "content" is missing?

Did you look at the xml?

        <item>
            <title><![CDATA[Parents plea to take Charlie home]]></title>
            <description><![CDATA[Chris Gard and Connie Yates's lawyer
accuses the hospital of "putting up obstacles".]]></description>

<link>http://www.bbc.co.uk/news/uk-england-london-40716292</link>
            <guid
isPermaLink="true">http://www.bbc.co.uk/news/uk-england-london-40716292</guid>
            <pubDate>Tue, 25 Jul 2017 13:58:55 GMT</pubDate>
            <media:thumbnail width="976" height="549"
url="http://c.files.bbci.co.uk/1132F/production/_97074407_mediaitem97074405.jpg"/>
        </item>

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

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

view rss item content alex <1j9448a02@lnx159sneakemail.com.invalid> - 2017-07-25 09:19 +0200
  Re: view rss item content "J.O. Aho" <user@example.net> - 2017-07-25 18:31 +0200
    Re: view rss item content alex <1j9448a02@lnx159sneakemail.com.invalid> - 2017-07-26 13:11 +0200

csiph-web