XML解析错误:第1行第769列的错误:编码错误 [英] XML Parse Error: error on line 1 at column 769: Encoding error
本文介绍了XML解析错误:第1行第769列的错误:编码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此问题是从此处开始的先前问题的扩展.
This question is an extension of a prevous question started here..
我添加了一段代码以列出姓名和电话号码.
i have added a snippet of code to list the names and phone numbers..
if(isset(${'Action'}) && ${'Action Type'}){
if(${'Action'} == 'get'){
if(${'Limit'} != ''){
$limit = ' LIMIT '.${'Limit'}.'';
} else {
$limit = '';
}
$i = 1;
${'Response'}['numbers'] = array();
${'Query'} = mysql_query('SELECT * FROM `crm`.`accounts` WHERE `acquired_via` = "Scrubbed account" AND `sent_to_dialer` = "0"'.$limit);
while(${'Row'} = mysql_fetch_assoc(${'Query'})){
${'Response'}['numbers']['number_'.$i] = array('Company_Name' => ${'Row'}['company_name'], 'Contact_First_Name' => ${'Row'}['contact_fname'], 'Contact_Last_Name' => ${'Row'}['contact_lname'], 'Office_Phone' => removeCHARSphone(${'Row'}['office_phone']), 'Mobile_Phone' => removeCHARSphone(${'Row'}['mobile_phone']));
$i++;
}
}elseif(${'Action'} == 'details'){
}
}
这会破坏XML
http://lmsapi.com/?api_key=b3e04e54f0d92f8845d394b61607; = get& format = xml http://lmsapi.com/?api_key=b3e04e54f0d92f8845d394b61c607d format = json
但是JSON保持不变...
But the JSON stays in tact...
推荐答案
您需要在XML内容中转义所有与号和尖括号.
You need to escape any ampersands and angle brackets in your XML content.
因此&
应该变成&
,<
应该变成<
并且>
应该变成>
.
So &
should become, &
, <
should become <
and >
should become >
.
最简单的方法可能是通过str_replace
调用,如下所示:
The easiest way to do that is probably with str_replace
call like this:
$string = str_replace(
array('&', '<', '>'),
array('&', '<', '>'),
$string);
这篇关于XML解析错误:第1行第769列的错误:编码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文