本文实例讲述了php使用simplexml_load_file加载xml文件并显示xml的方法。分享给大家供大家参考。具体实现方法如下:
<?php $xml = simplexml_load_file("sample.xml"); echo htmlspecialchars($xml->asxml()); ?>
sample.xml文件内容如下
<library> <book> <title>a</title> <author gender="female">b</author> <description>c</description> </book> <book> <title>c</title> <author gender="male">d</author> <description>e</description> </book> <book> <title>f</title> <author gender="male">g</author> <description>h</description> </book> </library>
希望本文所述对大家的php程序设计有所帮助。
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!