开发者

can't read XML via PHP

开发者 https://www.devze.com 2022-12-23 15:23 出处:网络
I can\'t find the reason, only see the following error message. Input is not proper UTF-8, indicate encoding ! Bytes: 0x00 0x5D 0x5D 0x3E

I can't find the reason, only see the following error message. Input is not proper UTF-8, indicate encoding ! Bytes: 0x00 0x5D 0x5D 0x3E

the followings are my php code

$reader2 = new XMLReader();
$reader2->XML($xmlstring);
$user_data="";

while ($reader2->read()) {

    if ($reader2->name == "user_id" && $reader2->nodeType == XMLReader::ELEMENT) {
        $reader2->read();
        $user_data .=$reader2->value;
    }


}
$reader2->close();

The followings are XML data

<?xml version="1.0" encoding="UTF-8" ?>
<SOAP:Envelope xmlns:SOAP="http://www.w3.org/2003/05/soap-envelope" >
    <SOAP:Body &开发者_如何学运维gt;
<user_id>1234567890</user_id>
<greeting_name><![CDATA[ABCDEF ..yl/�]]></greeting_name>
</SOAP:Body>
</SOAP:Envelope>

I try a lot of ways,but still can't find the solution. the greeting tag value may be chinese or English words.


Not all byte sequences encode a character in utf-8. There are sequences that have no meaning or - to put it blunt- are wrong. The xml parser found such a wrong sequence in the input document (which claims to be properly utf-8 encoded) and complained about it. The xml document needs to be fixed.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号