可能重复:
使用 CodeIgniter 创建 XML
$this->output->set_content_type('text/xml');
echo $this->dbutil->xml_from_result($query, $config) 
从上面的代码中,我看不到 XML 格式的数据集。在我的视图页面中,它以我之前看到的普通视图显示数据。
可能重复:
使用 CodeIgniter 创建 XML
$this->output->set_content_type('text/xml');
echo $this->dbutil->xml_from_result($query, $config) 
从上面的代码中,我看不到 XML 格式的数据集。在我的视图页面中,它以我之前看到的普通视图显示数据。
也许你应该试试这个
function user_get()
{
    if(!$this->get('id'))
    {
        $this->response(NULL, 400);
    }
        function users($id){
            $query = $this->db->get('student');
                    $this->db->where('EID', $id); 
            $config = array (
                              'root'    => 'users',
                              'element' => 'item',
                              'newline' => "\n",
                              'tab'    => "\t"
                            );
            $this->load->dbutil();
            echo '<?xml version="1.0" encoding="utf-8" ?> ';
            print $this->dbutil->xml_from_result($query, $config);
        } 
    $id = @$users[$this->get('id')];
    if($user)
    {
        $this->response($user, 200); // 200 being the HTTP response code
    }
    else
    {
        $this->response(array('error' => 'User could not be found'), 404);
    }
}