reading an rss file with php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tudortotolici
Forum Newbie
Posts: 1
Joined: Tue Nov 04, 2008 7:30 pm

reading an rss file with php

Post by tudortotolici »

I am trying to use the twitter search API to display results on my site.
But one of the tags is named <google:image_link>. I am a beginner. Do you have any idea how i can use this in php?
I tried this way:

Code: Select all

<td>" . $entry->google:image_link . "</td>
but i get the following error:
Parse error: syntax error, unexpected ':', expecting ',' or ';' in /home.....
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: reading an rss file with php

Post by requinix »

What are you using to read the XML?

Anyways, the "google" part marks a namespace. It's not part of the tag name (unless Twitter is breaking standards).
Somewhere in the XML is the URL with a page detailing information about the "google" namespace. For SimpleXML you need that URL and the ::children() function:

Code: Select all

echo (string)$xml->image_link; // doesn't work
 
$google = $xml->children("http://whatever.url/you/found/earlier");
echo (string)$google->image_link; // works
Post Reply