Page 1 of 1

reading an rss file with php

Posted: Tue Nov 04, 2008 7:33 pm
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.....

Re: reading an rss file with php

Posted: Tue Nov 04, 2008 8:22 pm
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