dongqi7631 2013-08-07 16:49
浏览 8
已采纳

和xml一起玩

I have this really poorly formed xml that in php I am able to get the contents of, the problem is that it strips the html tags

<content>
    <WhatsHere>
    <![CDATA[
            <h1>Content</h1>
    ]]>
    </WhatsHere>
    <WhatsComing>
    <![CDATA[
            <h2>I have no idea</h2>
    ]]>
    </WhatsComing>
</content>

I am essentially doing:

class CoreTheme_AdminPanel_Template_Helper_GrabUpdateContent{

    private $_xml_object_content = null;

    public function __construct(){
        if($this->_xml_object_content === null){
            $this->_xml_object_content = simplexml_load_file('http://adambalan.com/aisis/aisis_update/Test/update_notes.xml');
        }
    }

    public function whats_here(){
        $content = $this->_xml_object_content->WhatsHere[0];
        echo $content;
        return trim($content);
    }

}

When you call whats_here() you get <p>content</p> instead of <h1>content</h1> like you should.

  • 写回答

1条回答 默认 最新

  • douqianxian7008 2013-08-07 16:57
    关注

    It looks like this comment in the PHP help page for simplexml_load_file may apply to you, saying:

    So it seems SimpleXML doesn't support CDATA...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法