# Parsing Yahoo Weather with PHP & SimpleXML problem

**URL:** <https://forum.kirupa.com/t/parsing-yahoo-weather-with-php-simplexml-problem/239929>\
**Category:** programming\
**Created:** [September 27, 2007, 11:39am UTC](https://forum.kirupa.com/t/parsing-yahoo-weather-with-php-simplexml-problem/239929 "2007-09-27T11:39:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![opel](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/opel/32/199_2.png) [@opel](https://forum.kirupa.com/u/opel)\
**Post date:** [September 27, 2007, 11:39am UTC](https://forum.kirupa.com/t/parsing-yahoo-weather-with-php-simplexml-problem/239929/1 "2007-09-27T11:39:26Z")

</div>

I have been trying to parse the yahoo weather feed for inclusion on my site using PHP and SimpleXML. I am returning the feed correctly however when I put the feed through “simplexml\_load\_string” some of the attributes are not being parsed into my simpleXML object. These attributes are the main elements with weather info y:weather that are not appearing in my object.

I have scoured google, yahoo developer help and there tutorials and can see nothing about why my object may be broken.

Code so far is :

```php
<?php

$request = 'http://weather.yahooapis.com/forecastrss?p=34747';
//echo $request;

//make request using curl
$session = curl_init($request);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);

//get url and attach as img
$phpobject = simplexml_load_string($response);

$weather = $phpobject->channel[0];

	print '<p><img src="'.$weather->image->url.'" width="'.$weather->image->width.'" height="'.$weather->image->height.'" /></p>';
	print '<p><strong>'.$weather->description.'</strong></p>';
	

?>

```
