Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Mashup question

Go to End

3 Posts   1978 Views


Community Member, 22 Posts

9 August 2007 at 10:36pm

Edited: 09/08/2007 11:10pm

I want to integrate the weather from yahoo into my site.

The problem is that <yweather:condition text="Partly Cloudy" code="30" temp="15" date="Thu, 09 Aug 2007 10:55 am CEST" /> is not imported because of the ':'

Does someone know how to read element with column in SimpleXMLElement?

Is there a way to cash the output?


Google Summer of Code Hacker, 76 Posts

12 August 2007 at 1:01pm

Edited: 12/08/2007 1:02pm

Freeyland, if you want to read namespaced elements (qname) best practice would be to use Xpath. You could try out some query such as ;

$conditions = $xml->xpath("//yweather:condition");

But to make the whole process easy I've made an update to the mashups module which could handle such feeds. You can download the latest build in the trunk of mashups module and try out the following code. This will fetch the attribute values of condition tag in Yahoo Weather feed.

In your controller;

function YahooWeather(){
		$yw = new RestfulService("");
		$params = array(
				"u" => "c",
				"p" => "USIL0225"
		$conn = $yw->connect();
		$result = $yw->searchAttributes($conn, "//yweather:condition");
		return $result;

and in the template;
<% control YahooWeather %>
<p>weather conditions for $date<br/>
$text - tempreature -$temp</p>
<% end_control %>

Hope this helps :)

>>Is there a way to cash the output?
Currently Mashups module doesn't support caching, but it's something on the road maps for future releases.


Community Member, 22 Posts

13 August 2007 at 8:43am