mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-10 00:22:48 +08:00
改进xmlresponse
This commit is contained in:
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace think\response;
|
namespace think\response;
|
||||||
|
|
||||||
|
use think\Collection;
|
||||||
|
use think\Model;
|
||||||
use think\Response;
|
use think\Response;
|
||||||
|
|
||||||
class Xml extends Response
|
class Xml extends Response
|
||||||
@@ -81,6 +83,11 @@ class Xml extends Response
|
|||||||
protected function dataToXml($data, $item, $id)
|
protected function dataToXml($data, $item, $id)
|
||||||
{
|
{
|
||||||
$xml = $attr = '';
|
$xml = $attr = '';
|
||||||
|
|
||||||
|
if ($data instanceof Collection || $data instanceof Model) {
|
||||||
|
$data = $data->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($data as $key => $val) {
|
foreach ($data as $key => $val) {
|
||||||
if (is_numeric($key)) {
|
if (is_numeric($key)) {
|
||||||
$id && $attr = " {$id}=\"{$key}\"";
|
$id && $attr = " {$id}=\"{$key}\"";
|
||||||
|
|||||||
Reference in New Issue
Block a user