這篇文章主要介紹了php使用simplexml_load_file加載XML文件并顯示XML的方法,實(shí)例分析了simplexml_load_file操作XML文件的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了php使用simplexml_load_file加載XML文件并顯示XML的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
<?php
$xml = simplexml_load_file("sample.xml");
echo htmlspecialchars($xml->asXML());
?>
sample.xml文件內(nèi)容如下
<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>
希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。
更多信息請(qǐng)查看IT技術(shù)專欄