如何解析像本例这样的元素?
<?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>
<actor:view id='44' />
</character>
<character>
<name>Mr. Coder</name>
<actor>El ActÓr</actor>
<actor:view id='49' />
</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;
$simpleXml = new SimpleXMLElement($xmlstr);
var_dump((array) $simpleXml);命名空间错误:在第35行的/home/sweb/www/tmp/sxml.php中没有定义视图上的名称空间前缀参与者
在第35行的/home/sweb/www/tmp/sxml.php中
发布于 2010-08-08 06:57:29
XML解析器依赖于这样的事实:文档必须严格有效,而您的文档的格式并不好。它需要actor的命名空间URI。根元素应该遵循这样的思路:
<movies xmlns:actor="http://yoururl.com/">只要您没有它,任何兼容的XML解析器都不会接受您的文档。
https://stackoverflow.com/questions/3433387
复制相似问题