开发者

CakePHP - XML helper issue

I'm trying to spit out XML from an array.

So it almost work except that now I'm seeing this error "Resource interpreted as document but transferred with MIME type application/xml."

When I look at the source, what is being printed is

<?xml version="1.0" encoding="UTF-8" ?>
<response>
    ...
</response>
<?xml version="1.0" encoding="utf-8" ?>

How do I get rid of that second

<?xml version="1.0" encoding="utf-8" ?>

Seems like that automatically gets added.

This is the url I have cons开发者_StackOverflow中文版tructed /services/config.xml

Thanks,

Tee


Your view template should be located in the xml subfolder

/app/views/services/xml/config.ctp

The xml tag <?xml version="1.0" encoding="utf-8" ?> is then automatically rendered by the cake framework, so you should NOT have this tag in you config.ctp template. All you need to do is render your <response></response>.

Also, your services controller should render the content type HTTP header in the afterFilter:

function afterFilter()
{
    $this->header('Content-Type: application/xml'); 
}

Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜