Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php codeigniter 2.0到3.0 xml输出中断_Php_Xml_Codeigniter_Codeigniter Restserver - Fatal编程技术网

Php codeigniter 2.0到3.0 xml输出中断

Php codeigniter 2.0到3.0 xml输出中断,php,xml,codeigniter,codeigniter-restserver,Php,Xml,Codeigniter,Codeigniter Restserver,从2.0迁移到CI 3.0后,xml输出出现问题。我使用控制器上的以下代码通过restserver执行此操作: $xml = $this->_toRss($q); $this->response->format = 'xml'; $this->response($xml, 200 ); $xml是一个SimpleXMLElement,我使用如下代码创建和组装它: $xmlRoot = new SimpleXMLElement("<rss/>"); $xml

从2.0迁移到CI 3.0后,xml输出出现问题。我使用控制器上的以下代码通过restserver执行此操作:

$xml = $this->_toRss($q);
$this->response->format = 'xml';
$this->response($xml, 200 );
$xml是一个SimpleXMLElement,我使用如下代码创建和组装它:

$xmlRoot = new SimpleXMLElement("<rss/>");
$xml = $xmlRoot;
$xml->addAttribute("version", "1.0");

$channel = $xml->addChild("channel");
$channel->addChild("title", "My Company");
$channel->addChild("link", xml_convert($curURL));
$channel->addChild("description", "RSS feed");
$xmlRoot=新的SimpleXMLElement(“”);
$xml=$xmlRoot;
$xml->addAttribute(“版本”,“1.0”);
$channel=$xml->addChild(“channel”);
$channel->addChild(“标题”、“我的公司”);
$channel->addChild(“链接”,xml_转换($curURL));
$channel->addChild(“说明”、“RSS提要”);
代码在此迁移中没有更改

下面是一个在2.0上运行的响应示例:

下面是3.0上的响应示例:

这将在restserver上注册为一个bug,但对于需要它的人,这里有一个解决方法:

$this->output->set_status_header(200);
$this->output->set_content_type('application/xml', strtolower($this->config->item('charset')));
$this->output->set_output($xml->asXML());

这将在restserver上注册为一个bug,但对于需要它的人,这里有一个解决方法:

$this->output->set_status_header(200);
$this->output->set_content_type('application/xml', strtolower($this->config->item('charset')));
$this->output->set_output($xml->asXML());