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

[eluser]pixelknipsr[/eluser]
Hi there,

I hope that someone has the answer to my problem :-)

I'd like to pass a simplexml object from my controller to my view. Here's the code:
Code:
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://some-site.com/myData.xml';
        $xmlLoading = $this->loadxml($url);
        $xml = simplexml_load_string($xmlLoading);
        $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');                              
    }

The XML is correctly loaded and the $outputarray has the correct data are it. Still I get a "undefined variable" in my view :-( Can't I transfer such an object?

I also tried to pack everything into an array as described here: http://codingforums.com/showthread.php?t=87283 and it didn't work either.

Thanks for help me out.


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