Read <content:encoded> from RSS feed

Ask about a PHP problem here.
Post Reply
hostingebc
Posts: 28
Joined: Wed Jun 08, 2011 10:31 am

Read <content:encoded> from RSS feed

Post by hostingebc »

How to read <content:encoded> from RSS feed
for example, from this link ?
http://www.zurnal.rs/category/rukomet/feed?lang=lat
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Read <content:encoded> from RSS feed

Post by jacek »

Does the simpleXML extension not recognise it ?
Image
hostingebc
Posts: 28
Joined: Wed Jun 08, 2011 10:31 am

Re: Read <content:encoded> from RSS feed

Post 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)
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Read <content:encoded> from RSS feed

Post by jacek »

It may rename it to somethign for compatibility. Try doing
print_r($item);
and see if you can see the value anywhere ?
Image
hostingebc
Posts: 28
Joined: Wed Jun 08, 2011 10:31 am

Re: Read <content:encoded> from RSS feed

Post 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);
  ?>
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Read <content:encoded> from RSS feed

Post 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.
Image
hostingebc
Posts: 28
Joined: Wed Jun 08, 2011 10:31 am

Re: Read <content:encoded> from RSS feed

Post 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?
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Read <content:encoded> from RSS feed

Post 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 :?
Image
Post Reply