Page 1 of 1

Read <content:encoded> from RSS feed

Posted: Fri Jul 29, 2011 5:29 am
by hostingebc
How to read <content:encoded> from RSS feed
for example, from this link ?
http://www.zurnal.rs/category/rukomet/feed?lang=lat

Re: Read <content:encoded> from RSS feed

Posted: Fri Jul 29, 2011 2:14 pm
by jacek
Does the simpleXML extension not recognise it ?

Re: Read <content:encoded> from RSS feed

Posted: Fri Jul 29, 2011 6:22 pm
by hostingebc
jacek wrote:Does the simpleXML extension not recognise it ?
$encoded = $item->content; - not working (empty string is resolt)
$encoded = $item->encoded; - not working (empty string is resolt)
$encoded = $item->content:encoded; - not working (error)

Re: Read <content:encoded> from RSS feed

Posted: Fri Jul 29, 2011 6:58 pm
by jacek
It may rename it to somethign for compatibility. Try doing
print_r($item);
and see if you can see the value anywhere ?

Re: Read <content:encoded> from RSS feed

Posted: Sat Jul 30, 2011 10:38 am
by hostingebc
jacek wrote:It may rename it to somethign for compatibility. Try doing
print_r($item);
and see if you can see the value anywhere ?
No, condtent:encoded part, do not whow up on screen?

Can you help of andrsthend this example:
  <?php
    $rss = new SimpleXMLElement('http://www.naslovi.net/rss/sport/', null, true);
    $ns = $rss->getNamespaces(true);
    ?><h1><a href='<?php echo $rss->channel->link; ?>'><?php echo $rss->channel->title; ?></a></h1>
    <?php echo PHP_EOL?><hr /><?php echo PHP_EOL;
    $sql = "INSERT INTO `rss_vesti` VALUES";
    foreach($rss->xpath('channel/item') as $item)
    {
      preg_match('/<img[^>]+>/', $item->children($ns['content'])->encoded, $match);
      $item->image = $match[0]; 
      $naslov = $item->title;
      $link   = $item->link;
      $slika  = $item->image;
      $opis   = $item->description;
      $datum  = $item->pubDate;
      
      $sql.="('','','".$naslov."','".$slika."','".$opis."','".$link."','".$datum."'),";
    }
    //KRAJ PETLJE - INSERT upit
    $sql = substr($sql,0,-1).";";
    $result = mysql_query($sql,$konekcija);
  ?>

Re: Read <content:encoded> from RSS feed

Posted: Sat Jul 30, 2011 2:25 pm
by jacek
hostingebc wrote:No, condtent:encoded part, do not whow up on screen?
But did the value of that element ?
hostingebc wrote:Can you help of andrsthend this example:
Looks like it is getting some information from an RSS feed and putting it into a database.

also, please use the php button when posting code, not quotes.

Re: Read <content:encoded> from RSS feed

Posted: Sat Jul 30, 2011 2:54 pm
by hostingebc
jacek wrote: But did the value of that element ?
no
jacek wrote: Looks like it is getting some information from an RSS feed and putting it into a database.
yes i know that, but what is diference betwen my and this example (in my examle i have somtime problem with 30 second of execution of php code)

what is quicker ? (if you know)
what is better to use?

Re: Read <content:encoded> from RSS feed

Posted: Sat Jul 30, 2011 3:19 pm
by jacek
hostingebc wrote:no
Then I guess you will have to match it with a regular expression :?

Or try this more simple approach http://ja.meswilson.com/blog/2007/05/19 ... s-simpler/
hostingebc wrote:what is quicker ? (if you know)
what is better to use?
I have only seen one example :?