CI,如何在控制器中制作xml代码?

Actually I am coding Ajax and want to make a xml code in the controller file.

How could it be possible to write xml code in the controller file?

sample of what you want: in your CI controller:

class XML extends CI_Controller {

 public function my_function(){
   //your xml code here

   echo $xml_code; //echo your output
 } 
}

and in your script you might put something like this:

$(function() {

  $.ajax({
   url: '/XML/my_function/',
   type: 'POST', 
   dataType: 'string',
   success: function(response){
     //do what you want for response
   });
});

check the following links .

http://ellislab.com/codeigniter/user-guide/libraries/xmlrpc.html

https://github.com/EllisLab/CodeIgniter/wiki/XML-generator-library

Yes it is possible to generate xml file in controller:

simply create the xml in a variable

     $xml_builder = '<?xml version="1.0" encoding="utf-8"?>     
                                    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">  
                                    <soap:Body>     
                                    <Transact xmlns="http://Exxxx/xxxTopUp">    
                                                <LoginInfo>     
                                                        <AccountID>' . $account_id . '</AccountID>  
                                                        <Username>' . $username . '</Username>  
                                                        <Password>' . $password . '</Password>  
                                                        <BranchID>' . $branch_id . '</BranchID>     
                                                </LoginInfo>    
                                                <Telco>' . $telco . '</Telco>   
                                                <CellphoneNo>' . $cellphone_no . '</CellphoneNo>    
                                                <ExtTag>' . $Ext_tag . '</ExtTag> 
                                                <Amount>' . $amount . '</Amount>
                                                <Token>' . $token . '</Token> 
                                </Transact>     
                                </soap:Body>    
                                </soap:Envelope>';

Then We send XML via CURL using POST with a http header of text/xml.

    $url = "http://xxxxxxxxx.com/xxxtopup/";



    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_builder);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $ch_result = curl_exec($ch);