解决xml_parse(): input conversion failed due to input error

1.解决xml_parse(): input conversion failed due to input error

错误原因:xml中存在无法转换的字符;
解决:
步骤1、通过mb_detect_encoding函数,获取xml的编码;
步骤2、通过mb_convert_encoding函数转成指定的编码,或使用iconv,但编码参数需加上//IGNORE
步骤3:通过正则将<?xml …. encoding=”gb2312″ ..?>中的gb2312替换为指定编码;

原文地址:https://www.cnblogs.com/holyes/p/5f2b77b479124cd3e2d60c3f2bc2c2c5.html