Link to home
Start Free TrialLog in
Avatar of kent3800
kent3800

asked on

parse invalid RSS feed with no root elements to tranform into useable XML data

I have a feed that is not valid RSS nor standard and can not be changed. I would like to pull elements of this feed like recent snow fall and current temperature.

Can anyone tell me what I need to do to pull the data from this feed:
http://common.snow.com/adminincludes/rtp.resorts.vri.xml.asp

I'm using Zend_Feed_Reader but I get an error that says the Feed is Invalid or not supported.

I've also tried Zend_Dom_Query to get the data but I'm stuck in the arrays and am not sure how to pull that data out. I thought maybe there was an easier way to do this through XSL Transformation or something of the like.

Thanks for any guidance.
Avatar of kent3800
kent3800

ASKER

Here is an example of my path down Dom_Query land:

$url = 'http://common.snow.com/adminincludes/rtp.resorts.vri.xml.asp';
            $client = new Zend_Http_Client($url);
            $response = $client->request();
            $html = $response->getBody();
            $dom = new Zend_Dom_Query($html);
            
            if(sizeof($dom->query('resort')) > 0) {
                  $resort = $dom->query('resort');
            } else {
                  $resort = NULL;
            }
            
            if($resort != NULL) {
                  foreach($resort as $index=>$result) {
                        if($result->nodeValue !== '') {
                              $resort = $result->nodeValue;
                        }
                  }
            }
            
            $data = array(
                  'resort'=>$resort,
                  'other'=>'variable'
            );
            $xml = (object) $data;
            var_dump($xml); die;

This is the dump with $resort not holding any data:
object(stdClass)#53 (2) { ["resort"]=> string(27) " " ["other"]=> string(8) "variable" }

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial