getDocNamespaces() 函數(shù)從 SimpleXMLElement 對象返回在 XML 文檔中聲明的命名空間。
如果成功,該函數(shù)返回包含命名空間名稱(帶有關聯(lián)的 URL)的數(shù)組。如果失敗,則返回 false。
class SimpleXMLElement { string getDocNamespaces(recursive) }
參數(shù) | 描述 |
---|---|
recursive | 可選。規(guī)定是否返回父子節(jié)點中的所有命名空間。默認是 false。 |
XML 文件:
<?xml version="1.0" encoding="ISO-8859-1"?> <note xmlns:b="http://theartemis.cn/example/"> <to>George</to> <from>John</from> <heading>Reminder</heading> <b:body>Don't forget the meeting!</b:body> </note>
PHP 代碼:
<?php
if (file_exists('test.xml'))
{
$xml = simplexml_load_file('test.xml');
}
print_r($xml->getDocNamespaces()
);
?>
輸出類似:
Array ( [b] => http://theartemis.cn/example/ )
如對本文有疑問,請?zhí)峤坏浇涣髡搲?,廣大熱心網(wǎng)友會為你解答?。?點擊進入論壇
Powered by 365建站網(wǎng) RSS地圖 HTML地圖
copyright © 2013-2024 版權所有 鄂ICP備17013400號