Php codeigniter 2.0到3.0 xml输出中断
从2.0迁移到CI 3.0后,xml输出出现问题。我使用控制器上的以下代码通过restserver执行此操作: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
$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());