我使用simpleXml来解析我的xml,但是当我尝试解析西班牙语,法语,爱沙尼亚语,葡萄牙语,上标或下标时,它总是打破页面。
任何想法?
XML示例: -
<carddata> <logo_id>0</logo_id> <cscale>Ñ</cscale><carddata>
脚本: -
$carddetail = new SimpleXMLElement($xml);
$carddetail = iconv('UTF-8', 'ISO-8859-15//TRANSLIT', $carddetail);
在我发送的xml中
<cscale><![CDATA[Peter Nortoné]]></cscale>
,错误是:
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 22: parser error : CData section not finished Peter Nort in D:\xampp\htdocs\logosnap\card.php on line 144
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <text><\![CDATA[Peter Norton in D:\xampp\htdocs\logosnap\card.php on line 144
答案 0 :(得分:1)
$carddetail = new SimpleXMLElement($xml);
<-- this set $carddetail as simplexmlelement object
您不能将对象用作字符串,如: -
$carddetail = iconv('UTF-8', 'ISO-8859-15//TRANSLIT', $carddetail);
所以,试试这个: -
$carddetail = new SimpleXMLElement(iconv('UTF-8','ISO-8859-15//TRANSLIT',$xml));