相关疑难解决方法(0)

从SimpleXML访问@attribute

我在访问@attributeSimpleXML对象的部分时遇到问题.当我var_dump整个对象,我得到正确的输出,当我var_dump对象的其余部分(嵌套标签),我得到正确的输出,但当我按照文档var_dump $xml->OFFICE->{'@attributes'},我得到一个空对象,尽管事实上第一个var_dump清楚地表明有输出的属性.

任何人都知道我在这里做错了什么/我如何才能做到这一点?

php xml simplexml

113
推荐指数
7
解决办法
13万
查看次数

如何使用SimpleXML解析XML的CDATA HTML内容?

我正在尝试将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='&lt;br&gt;November 2012 calendar from 5.10 The Test&lt;br&gt; &lt;a href=&quot;</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)

html php xml rss simplexml

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

php ×2

simplexml ×2

xml ×2

html ×1

rss ×1