我在XML文件中的下列内容:帮助与XML,PHP和CDATA
<items>
<item id="1"><content><![CDATA[<p>string</p>]]></content></item>
</items>
我有HTML里面的内容,所以,我用CDATA。然而,当我试图显示网页上的内容为HTML:
$item_content = $xpath2->query("/bulletin/item[@id='$item_id']/content");
foreach ($item_content as $i)
{
$a = $dom->createElement('div');
$a->appendChild($dom->createCDATASection($i->nodeValue));
// $child = $dom->createElement('div',$i->nodeValue); <--this fails miserably
$content_tag->appendChild($a);
}
它会得到显示为:
& LT,P & GT;字符串& LT;/P & GT ;
如何将其显示为HTML?
你为什么要使用DOM输出HTML在PHP?为什么不直接在'echo $ i-> nodeValue'中直接回显? – Ramon
我必须修改现有的应用程序...我会看到我可以做的回声。 – Tower