当我尝试创建SimpleXMLElement
.
我使用在线工具手动检查了我的 xml 语法,甚至从php.net复制/粘贴了示例 XML 文件,但我仍然收到错误消息。
我的代码:
include 'example.php';
$namevalues= new SimpleXMLElement($xmlstr);
例子.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;
?>
错误:
致命错误:第 266 行 C:\AbyssRoot\htdocs\Forum\Sources\showhomework.php 中的未捕获异常 'Exception' 和消息 'String could not be parsed as XML'