Home  >  Article  >  php教程  >  php5的simplexml解析错误

php5的simplexml解析错误

WBOY
WBOYOriginal
2016-06-13 10:59:32981browse

  前阵子用simplexml来解析一个rss数据源,很轻松就获得了想要的结果.不想没几天就开始报错:

Warning: simplexml_load_file() [function.simplexml-load-file]: input conversion failed due to input error, bytes 0xAD 0xB5 0x3C 0x2F

  刚开始猜想是php5的一个bug,但是搜索发现,有可能是rss源内混杂了其它编码的字符,导致simplexml解析错误.

  也就是说,如果rss的声明是这样子:

PLAIN TEXTXML:

那么rss内容一定要是gb2312.

解决办法

用iconv转换编码

修改encoding为正确的编码


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php文件怎么打开Next article:ubuntu下安装php5+pdo