我正在使用PSWebServiceLibrary.php进行prestashop,而在add
函数中,这是发送xml请求进行解析的代码。我有
self::checkStatusCode($request['status_code']);
$res = trim($request['response'] );
var_dump($res);
return self::parseXML($request['response']);
这是var_dump的输出:
string(1459) "<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<customer>
<id><![CDATA[220]]></id>
<id_default_group></id_default_group>
<id_lang xlink:href="http://elpakhsh.com/api/languages/2"><![CDATA[2]]></id_lang>
<newsletter_date_add><![CDATA[2017-07-12 10:50:46]]></newsletter_date_add>
<ip_registration_newsletter></ip_registration_newsletter>
<last_passwd_gen><![CDATA[2017-07-12 04:50:46]]></last_passwd_gen>
<secure_key><![CDATA[95bb810ab3d387bc7eb249030ec06233]]></secure_key>
<deleted></deleted>
<passwd><![CDATA[e95db4822affea261aad478059f75457]]></passwd>
<lastname><![CDATA[مشتری]]></lastname>
<firstname><![CDATA[مشتری]]></firstname>
<email><![CDATA[navid.abutorab@gmail.com]]></email>
<id_gender></id_gender>
<birthday></birthday>
<newsletter><![CDATA[1]]></newsletter>
<optin><![CDATA[1]]></optin>
<website></website>
<company></company>
<siret></siret>
<ape></ape>
<outstanding_allow_amount></outstanding_allow_amount>
<show_public_prices></show_public_prices>
<id_risk></id_risk>
<max_payment_days></max_payment_days>
<active><![CDATA[1]]></active>
<note></note>
<is_guest></is_guest>
<id_shop><![CDATA[1]]></id_shop>
<id_shop_group><![CDATA[1]]></id_shop_group>
<date_add><![CDATA[2017-07-12 10:50:46]]></date_add>
<date_upd><![CDATA[2017-07-12 10:50:46]]></date_upd>
<associations>
<groups nodeType="group" api="groups"/>
</associations>
</customer>
</prestashop>"
从输出中可以看出,开头没有空格但我仍然遇到错误
HTTP XML响应无法解析:array(0 =&gt; LibXMLError :: __ set_state(array('level'=&gt; 3,'code'=&gt; 64,'column' =&GT; 7,'message'=&gt; 'XML声明只允许在文档的开头','file'=&gt; '','line'=&gt; 1,)),)
问题是什么?我的xml有什么问题吗?我已经验证了它并没有问题..