Welcome Guest, Not a member yet? Register   Sign In
SimpleXML Object is not passed to view
#3

[eluser]pixelknipsr[/eluser]
Hi Raiko,

Thanks pointing out my error in the loadxml function.

Here's my little class:
Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Listing extends Controller {
    function Listing()
    {
        parent::Controller();
    }
    function loadxml($url)
    {
        $curl_handle=curl_init();
        curl_setopt($curl_handle,CURLOPT_URL,$url);
        curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,3);
        curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
        return curl_exec($curl_handle);
        curl_close($curl_handle);
    }
    
    function Index()
    {
        $url = 'http://www.ricardo.ch/Default/GetXMLListing.asp?catg=1&listingtype=7&listingsort=1&MaxPerPage=2';
        $xmlLoading = $this->loadxml($url);
        $xml = simplexml_load_string($xmlLoading);
        print_r($xml); // $xml is loaded correctly
        $outputarray = array();
        if ($xml) {
            foreach ($xml->Auctions->Auction as $auction) {
                array_push($outputarray, $auction);
            }
        }
        $this->load->view('header');
        $this->load->view('listing_view', $outputarray);
        $this->load->view('footer');                              
    }
}
?>

And here's my view:
Code:
<?php
print_r($outputarray);
?>

I get this error:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: outputarray
Filename: views/listing_view.php
Line Number: 2


Messages In This Thread
SimpleXML Object is not passed to view - by El Forum - 06-20-2008, 02:22 AM
SimpleXML Object is not passed to view - by El Forum - 06-20-2008, 06:55 AM
SimpleXML Object is not passed to view - by El Forum - 06-20-2008, 07:22 AM
SimpleXML Object is not passed to view - by El Forum - 06-20-2008, 07:43 AM
SimpleXML Object is not passed to view - by El Forum - 06-20-2008, 08:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB