2 回答

TA貢獻(xiàn)1826條經(jīng)驗(yàn) 獲得超6個(gè)贊
你不必使用simplexml_load_file: 還有另一個(gè)函數(shù)來(lái)讀取文件,這個(gè)函數(shù)是file_get_contents($filename).
這是一個(gè)簡(jiǎn)單的代碼使用:
<?php
// Set the encoding to XML
header('Content-type: text/xml');
// Get contents of the file
$xml = file_get_contents("xmlfile.xml") ;
// Print contents
echo $xml;
?>
我希望它對(duì)你有幫助!并對(duì)語(yǔ)言錯(cuò)誤感到抱歉;)

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超9個(gè)贊
試試這個(gè)代碼。這個(gè)對(duì)我有用。
<?php
header("Content-type: text/xml");
$yourFile = "xmlfile.xml";
$file = file_get_contents($yourFile);
echo $file;
如果你堅(jiān)持使用簡(jiǎn)單的 xml,你可以這樣寫(xiě)。
$xml = simplexml_load_file("xmlfile.xml");
echo $xml->asXML();
- 2 回答
- 0 關(guān)注
- 192 瀏覽
添加回答
舉報(bào)