gpt4 book ai didi

php - 使用 NuSOAP 检索结果时出现 XML 错误(无效字符)

转载 作者:可可西里 更新时间:2023-10-31 22:46:02 25 4
gpt4 key购买 nike

我正在使用 NuSOAP 与第三方 API 交互,包括运行数据库查询和检索结果。它一直工作得相当可靠,但我只是遇到了一个特定查询的问题。 NuSOAP 没有返回结果,而是生成了一个错误:XML error parsing SOAP payload on line 2: Invalid character

原来结果集包含以下内容:Léa Lincoln。当我手动将重音字符更改为“常规”字符时,查询工作正常,没有来自 NuSOAP 的错误。

所以,我的问题是如何处理这件事。我无法控制来自数据库的数据,我需要 NuSOAP 在每次出现非标准字符时都不会抛出错误并停止。谢谢。 --杰夫

最佳答案

在搜索和测试之后,CAZypedia 团队的破解似乎是解决方案:

function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){
parent::nusoap_base();

// Hack by CAZypedia crew to fix character encoding of NCBI XML data from SOAP
// This prevents non-English characters from causing the parser to choke.
$xml = iconv("ISO-8859-1", "UTF-8//TRANSLIT", $xml);
// End hack.
$this->xml = $xml;
$this->xml_encoding = $encoding;
$this->method = $method;
$this->decode_utf8 = $decode_utf8;

链接:http://sourceforge.net/projects/nusoap/forums/forum/193579/topic/3718945

关于php - 使用 NuSOAP 检索结果时出现 XML 错误(无效字符),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11161391/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com