CodeIgniter Forums
XML from result Need HELP! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: XML from result Need HELP! (/thread-53417.html)



XML from result Need HELP! - El Forum - 07-23-2012

[eluser]prasie[/eluser]
Code:
<?php
$this->load->dbutil();

$data = $this->session->userdata('data_services');

                if($data['maskapai'] == 0)
             {
                 $airlines = array('airasia','batavia', 'citilink','lion', 'sriwijaya');
             }
             elseif($data['maskapai'] == 1)
             {
                 $airlines = array('airasia');
             }
             elseif($data['maskapai'] == 2)
             {
                 $airlines = array('batavia');
             }
             elseif($data['maskapai'] == 3)
             {
                 $airlines = array('citilink');
             }
             elseif($data['maskapai'] == 4)
             {
                        $airlines = array('garuda');
             }
                    elseif($data['maskapai'] == 5)
             {
                        $airlines = array('lion');
             }
                    elseif($data['maskapai'] == 6)
             {
                       $airlines = array('sriwijaya');
             }
                
                        $from = $data['from'];
                        $to = $data['to'];
                        $depdate = $data['depdate'];
                        $retdate = $data['retdate'];
                        $pax = $data['pax'];
                        $where1 ="(`from` = '$from' and `to` = '$to' and depdate = '$depdate' and pax = '$pax') ";
                        $where2 = "(`from` = '$to' and `to` = '$from' and depdate = '$retdate' and pax = '$pax')";
                        
               if ($data['returnType'] == 'RT')
               {
                $this->db->where($where1);    
    $this->db->where_in('airline', $airlines);
                $this->db->where('last_update >=', time()-7200);
                $this->db->or_where($where2);    
    $this->db->where_in('airline', $airlines);
                $this->db->where('last_update >=', time()-7200);
               }
               elseif ($data['returnType'] == 'OW')
               {
                $this->db->where($where1);    
    $this->db->where_in('airline', $airlines);
                $this->db->where('id','');
               }
   $query = $this->db->get('ticket_cache');

$config = array (
                  'root'    => 'root',
                  'element' => 'element',
                  'newline' => "\n",
                  'tab'     => "\t"
                );

$xml = $this->dbutil->xml_from_result($query,$config);
$this->session->unset_userdata('data_services');
$this->output->set_content_type('text/html');
$this->output->set_output($xml);
?>

all code running fine at my localhost and return the xml correctly
but when try to upload to myserver suddenly there is additional div dunno why seems yesterday works good , will appreciate any suggestion try to google seems find nothing
Code:
<div id="resdebug_scrap_result">pre>Array
(
)
</pre></div>



XML from result Need HELP! - El Forum - 07-23-2012

[eluser]Clooner[/eluser]
Try using direct output using exit($xml) and not $this->output->set_output($xml) and see the result. Also you should set the content type to xml and not html!




XML from result Need HELP! - El Forum - 07-23-2012

[eluser]rip_pit[/eluser]
i output xml with something like:
Code:
$this->output->set_header("Content-Type: application/xml");
    $data['starttag'] = '&lt;?xml version="1.0" encoding="UTF-8"?&gt;';
    $feed = $this->load->view('front/rss', $data, true);
    $this->output->set_output($feed);

the rss file contains the xml elements, like:

Code:
echo $starttag;
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  
  <channel>
    <category>title0</category>
    &lt;link&gt;url0&lt;/link&gt;


      <item>
        &lt;title&gt;title 1&lt;/title&gt;
        &lt;link&gt;url1&lt;/link&gt;
      </item>

      <item>
        &lt;title&gt;title 2&lt;/title&gt;
        &lt;link&gt;url2&lt;/link&gt;
      </item>


  </channel>
</rss>

i had problem including xml tag directly in the rss file itself it's why i have it in the controller.


XML from result Need HELP! - El Forum - 07-23-2012

[eluser]prasie[/eluser]
i found the problem -_- seems my friends echo that div to debug the result that why returns that error, and my local have no problem cause of that one


XML from result Need HELP! - El Forum - 07-26-2012

[eluser]rip_pit[/eluser]
be sure the profiler is disabled too Wink