這篇文章主要介紹了php使用simplexml_load_file加載XML文件并顯示XML的方法,實例分析了simplexml_load_file操作XML文件的技巧,非常具有實用價值,需要的朋友可以參考下
本文實例講述了php使用simplexml_load_file加載XML文件并顯示XML的方法。分享給大家供大家參考。具體實現(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>
希望本文所述對大家的php程序設(shè)計有所幫助。
更多信息請查看IT技術(shù)專欄