[eluser]floweringmind88[/eluser]
I am doing the following to try and load and use this class:
Code:
$this->load->library('xml');
$data = $this->xml->xml_load_file($xmlfile);
I get the following error:
Fatal error: Call to a member function on a non-object
Here is the function in the xml class:
Code:
function xml_load_file($file, $resulttype = 'object', $encoding = 'UTF-8')
{
$php_errormsg="";
$this->result="";
$this->evalCode="";
$values="";
$data = file_get_contents($file);
if (!$data)
return 'Cannot open xml document: ' . (isset($php_errormsg) ? $php_errormsg : $file);
$parser = xml_parser_create($encoding);
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
$ok = xml_parse_into_struct($parser, $data, $values);
if (!$ok) {
$errmsg = sprintf("XML parse error %d '%s' at line %d, column %d (byte index %d)",
xml_get_error_code($parser),
xml_error_string(xml_get_error_code($parser)),
xml_get_current_line_number($parser),
xml_get_current_column_number($parser),
xml_get_current_byte_index($parser));
}
xml_parser_free($parser);
if (!$ok)
return $errmsg;
if ($resulttype == 'array')
return $this->xml_reorganize($values);
// default $resulttype is 'object'
return $this->array2object($this->xml_reorganize($values));
}