1
当我尝试创建SimpleXMLElement
的新实例时,我不断收到此错误。“字符串不能被解析为XML”php错误
我手动检查了我的xml语法和在线工具,甚至复制/粘贴了php.net中的示例XML文件,但我仍然收到错误消息。
我的代码:
include 'example.php';
$namevalues= new SimpleXMLElement($xmlstr);
的使用example.php:
<?php
$xmlstr = <<<XML
<?xml version='1.0' standalone='yes'?>
<movies>
<movie>
<title>PHP: Behind the Parser</title>
<characters>
<character>
<name>Ms. Coder</name>
<actor>Onlivia Actora</actor>
</character>
<character>
<name>Mr. Coder</name>
<actor>El ActÓr</actor>
</character>
</characters>
<plot>
So, this language. It's like, a programming language. Or is it a
scripting language? All is revealed in this thrilling horror spoof
of a documentary.
</plot>
<great-lines>
<line>PHP solves all my web problems</line>
</great-lines>
<rating type="thumbs">7</rating>
<rating type="stars">5</rating>
</movie>
</movies>
XML;
?>
错误:
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\AbyssRoot\htdocs\Forum\Sources\showhomework.php on line 266
http://se.php.net/manual/en/simplexml.examples-errors.php – 2012-07-07 09:09:44
测试上述代码中,正常工作中的“PHP 5.3.10-PL0-巴布亚(CLI) “ – 2012-07-07 09:14:59