dovhpmnm31216 2009-04-24 00:04
浏览 58
已采纳

什么php函数可以从XML文件中显示格式化的XHTML?

Ive been trying to display formatted content blocks from a xml file with no luck. Ive been using simplexml_load_file and other varients which Im now seeing cannot deal with the xhtml tags within the called tag ... eg.

//php contents
 <?php $xml=simplexml_load_file("file.xml");
 echo ($xml->entry); ?>

//xml contents
 <entry>
 <p>This does not work</p>
 </entry>

whereas

 <entry>This works</entry>

can someone please tell me which php function can do this from an xml file and or what is the best way to display the contents with xhtml formatting?

Im trying to dynamically load content to a webpage without having to build too many pages. I like the idea of having all my content in one xml file for easy edits.

Theres not enough content to justify a database yet.

Thanks in advance

  • 写回答

2条回答 默认 最新

  • dqj5046 2009-04-24 00:19
    关注

    You can try dumping the contents of a certain simplexml node (in this case: $xml->entry) using the asXml function.

    echo $xml->entry->asXml();
    

    Check the php documentation on simplexml here (link to the asXml() call):

    Simplexml documentation

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端