Welcome Guest, Not a member yet? Register   Sign In
Unable to load the requested class: simplexml
#1

[eluser]Unknown[/eluser]
Hello, I think all are fine.

In learning framework i am facing many problem, from which maximum problem i can solve myself.

But now a problem giving me very botheration.

To read a xml file, my code which i have kept in controller


Code:
class Xml extends CI_Controller {

function index()
{
  //load the parser library
  $this->load->library('parser');

               $data['title'] = 'Parsing XML using Simplexml class of CodeIgniter';

               $data['products'] = $this->_getXML('new');

        $this->parser->parse('xml_view', $data);
}
    function _getXML($fname)
    {
                $filename = $fname.'.xml';
                
$xmlfile="http://www.acerdriversupdateutility.com/acer-travelmate-4060-drivers-utility.xml";
                $xmlRaw = file_get_contents($xmlfile);

                $this->load->library('simplexml');
                $xmlData = $this->simplexml->xml_parse($xmlRaw);

                foreach($xmlData['item'] as $row)
                {
   $result .= '<tr>';
   $result .= '<td>'.$row['XML_DIZ_INFO'].'</td>';
   $result .= '<td>'.$row['RoboSoft'].'</td>';
   $result .= '<td>'.$row['category'].'</td>';
   $result .= '<td>$ '.$row['price'].'</td>';
   $result .= '</tr>';
                }
                return $result;
      }
}


by running the page showing error

An Error Was Encountered
Unable to load the requested class: simplexml


what can i do here?
#2

[eluser]skunkbad[/eluser]
Simplexml is part of php 5. What version php are you on?
#3

[eluser]Unknown[/eluser]
Thanks Mr. skunkbad.

I am using PHP Version 5.1.2
#4

[eluser]skunkbad[/eluser]
Oh, I should have looked at your code. You don't need to load simplexml, and you don't use it with $this->simplexml. Just look in the docs at php.net for proper usage.




Theme © iAndrew 2016 - Forum software by © MyBB