为了账号安全,请及时绑定邮箱和手机立即绑定

error on line 2 at column 1: Extra content at the end of the document

This page contains the following errors:

error on line 2 at column 1: Extra content at the end of the document

Below is a rendering of the page up to the first error.



这是我封装的xml格式数据,  写的跟老师的一样,  一旦调用测试就报这个错误,  纠结中,  求助

源代码如下:


public static function xmlEncode($code,$message="",$data)

{

if(!is_numeric($code))

{

return "";

}

$result=array(

'code'=>$code,

'message'=>$messgae,

'data'=>$data

);

header("Content-Type:text/xml");

$xml = "<?xml version='1.0' encoding='UTF-8'?>\n";

$xml .= "<root>";

$xml .= self::xmlToEncode($result);

$xml .= "</root>";

echo $xml;

}

public static function xmlToEncode($data)

{

$xml = "";

foreach ($data as $key => $value) {

$addr = "";

if(is_numeric($key)){

$addr = "id='{$key}'";

$key = 'item';

}

$xml .= "<{$key}{$addr}>";

$xml .= is_array($value) ? self::xmlToEncode($value) : $value;

$xml .= "</{$key}>\n";

}

return $xml;

}



正在回答

举报

0/150
提交
取消
PHP开发APP接口
  • 参与学习       79185    人
  • 解答问题       599    个

APP通信接口技术,不得不掌握的法宝,学完之后你会受益良多

进入课程

error on line 2 at column 1: Extra content at the end of the document

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信