我怎样才能像这个例子一样解析元素
<?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);
命名空间错误:视图上的命名空间前缀 actor 未在第 35 行的 /home/sweb/www/tmp/sxml.php 中定义
在 /home/sweb/www/tmp/sxml.php 第 35 行
XML 解析器依赖于这样一个事实:文档必须严格有效,而您的文档格式不正确。它需要一个命名空间 URIactor
。根元素应该是这样的:
<movies xmlns:actor="http://yoururl.com/">
只要您没有它,任何兼容的 XML 解析器都不会接受您的文档。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)