关于xml:php中的simplexml_load_file()错误

simplexml_load_file() error in php

我已经使用php创建了一个测试xml,其内容在gujrati中

1
2
3
$doc = new DomDocument('1.0','UTF-8');
$fieldvalue = mb_convert_encoding($question['questiontext'],'ISO-8859-1','UTF-8');
$value2 = $doc->createTextNode($fieldvalue);

XML文件创建成功,但是当我尝试使用simplexml_load_file函数呈现XML内容时,出现以下错误:

Warning: simplexml_load_file() [function.simplexml-load-file]: testsxml/test27_4.xml:2: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xC9 0xD6 0xF7 0x20


我也遇到过同样的问题,可以通过使用utf8encode解决。 我看到您使用了多字节版本,但是尝试一下可能值得一试。 还要确保您没有对事物进行两次编码。

还有一件事。 我想DomDocument会为您完成此操作,但是请检查&是否为&等等。