XML解析错误:第1行第769列的错误:编码错误 [英] XML Parse Error: error on line 1 at column 769: Encoding error

查看:165
本文介绍了XML解析错误:第1行第769列的错误:编码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题是从此处开始的先前问题的扩展.

This question is an extension of a prevous question started here..

> XML解析错误-额外内容文件结尾

我添加了一段代码以列出姓名和电话号码.

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.

因此&应该变成&amp;<应该变成&lt;并且>应该变成&gt;.

So & should become, &amp;, < should become &lt; and > should become &gt;.

最简单的方法可能是通过str_replace调用,如下所示:

The easiest way to do that is probably with str_replace call like this:

$string = str_replace(
  array('&', '<', '>'),
  array('&amp;', '&lt;', '&gt;'),
  $string);

这篇关于XML解析错误:第1行第769列的错误:编码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆