2012-04-28 2 views
-1

Можно создать дубликат:
XML creation using CodeIgniterXML вид страницы из Codeigniter

$this->output->set_content_type('text/xml'); 
echo $this->dbutil->xml_from_result($query, $config) 

Из выше кода, который я не могу видеть набор данных в формате XML. На моей странице просмотра отображаются данные в обычном виде, как я видел раньше.

+0

Я отправил правку мой ответ на ваш другой (такой же) вопрос, который должен помочь вам. –

ответ

0

может быть, вы должны попробовать это

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); 
    } 

} 
Смежные вопросы