1

我正在尝试将插件从 cakephp 1.3 迁移到 2.x。

原始代码

        App::import('Core', 'Xml');
        $Xml = new Xml($response);
        $response = $Xml->toArray(false); // Send false to get separate elements
        $Xml->__destruct();
        $Xml = null;

我认为在 cakephp 2.x app::import('Core', 'Xml'); 世界成为App::import('Utility', 'Xml'); 我应该使用Xml::toArray(Xml::build($response)); . 然后我被卡住了。我很感激任何帮助。

4

1 回答 1

3

不,它会变成

App::uses('Xml', 'Utility');

因为 App::import() 现在仅适用于非类文件和供应商文件。

然后你可以像这样使用它:

$xml = Xml::build($filenameOrXmlContent);
$array = Xml::toArray($xml);

http://book.cakephp.org/2.0/en/core-utility-libraries/xml.html

于 2013-01-16T09:19:52.317 回答