将数据发布到XML格式的另一个URL

This is the first controller xmlPost.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


Class XmlPost extends CI_controller
{

public function index()
{

    $this->load->view('my_view');

    $data["id"] = $this->input->post("id");
    $this->load->library('session');
    $this->session->set_flashdata('$my_var' , $data["id"]);
    redirect('/xmlReceive/r_data/');
    }
}
?>

this is the second controller xmlReceive.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


Class XmlReceive extends CI_controller
{
public function r_data()
{
    $this->load->library('session');
    $my_var = $this->session->flashdata('$my_var');
    echo $my_var;


   }
}
?>

this is the view for taking input in a test box

<html>

<form method="post" action="<?php echo base_url();?>xmlPost/index">

<input type="text" name="id" />


<input type="submit" value="submit"/>

</form>
</html>

what i am trying to do is take something input from a view and hold it in a controller xmlPost.php and then pass it to another controller xmlReceive.php. now everything is working fine.

the problem is when put some XML data in the text box in the xmlReceive.php controller I get the data without any xml tag like if in insert

<?xml version="1.0" encoding="utf-8"?>
<?ADF version="1.0"?>
<adf>
<prospect><id sequence="1" source="xxxs">37</id>
</adf>

in the text box and click submit I get only 37 in the xmlReceive.php but i want to get the output with the xml tags i.e. the way i inserted

how can i solve this problem

The reason the xml is not showing is because the browser assumes your using HTML, so to be able to view it in a browser you would need to tell it otherwise i.e.:

header('content-type: text/xml');

(Note: the example you've given above will error because there isn't a closing tag for <prospect>).

The other option is to echo the content inside htmlentities() and then use html_entity_decode() to convert the content from HTML back to XML for when you want to write it to a file.

Hope this helps!