我在访问@attributeSimpleXML对象的部分时遇到问题.当我var_dump整个对象,我得到正确的输出,当我var_dump对象的其余部分(嵌套标签),我得到正确的输出,但当我按照文档var_dump $xml->OFFICE->{'@attributes'},我得到一个空对象,尽管事实上第一个var_dump清楚地表明有输出的属性.
任何人都知道我在这里做错了什么/我如何才能做到这一点?
我正在尝试将Xml内容显示到表中,所有工作都很完美,但标签中的一些内容我不想显示,我只想要图像但不是
2012年11月日历从5.10测试
像在xml中一样 <content:encoded><![CDATA[<p>November 2012 calendar from 5.10 The Test</p>
<p><a class="shutterset_" href='http://trance-gemini.com/wordpress/wp-content/gallery/calendars/laura-bertram-trance-gemini-145-1080.jpg' title='<br>November 2012 calendar from 5.10 The Test<br> <a href="</a></p>]]>
</content:encoded>
Run Code Online (Sandbox Code Playgroud)
我想显示图像但不是
2012年11月日历从5.10测试
.<?php
// load SimpleXML
$item = new SimpleXMLElement('test1.xml', null, true);
echo <<<EOF
<table border="1px">
<tr cl>
</tr>
EOF;
foreach($item->channel->item as $boo) // loop through our books
{
echo <<<EOF
<tr>
<td rowspan="3">{$boo->children('content', true)->encoded}</td>
<td>{$boo->title}</td>
</tr>
<tr>
<td>{$boo->description}</td>
</tr>
<tr>
<td>{boo->comments}</td>
</tr>
EOF;
}
echo '</table>';
?>
Run Code Online (Sandbox Code Playgroud)