PHP getDocNamespaces() 函數
實例
返回 XML 文檔的根節點中聲明的命名空間:
?php
$xml=XML
?xml version="1.0" standalone="yes"?>
cars xmlns:c="http://codingdict.com/ns">
c:car id="1">Volvo/c:car>
c:car id="2">BMW/c:car>
c:car id="3">Saab/c:car>
/cars>
XML;
$sxe=new SimpleXMLElement($xml);
$ns=$sxe->getDocNamespaces();
print_r($ns);
?>
定義和用法
getDocNamespaces()
函數返回 XML 文檔中聲明的命名空間。
語法
getDocNamespaces( _recursive_ , _from_root_ );


實例 1
返回 XML 文檔的父節點和子節點中聲明的所有命名空間:
?php
$xml=XML
?xml version="1.0" standalone="yes"?>
cars xmlns:c="http://codingdict.com/ns">
c:car id="1">Volvo/c:car>
c:car id="2">BMW/c:car>
c:car id="3" a:country="Sweden"
xmlns:a="http://codingdict.com/country">Saab/c:car>
/cars>
XML;
$sxe=new SimpleXMLElement($xml);
$ns=$sxe->getDocNamespaces(TRUE);
var_dump($ns);
?>
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。如果你想了解更多相關內容請查看下面相關鏈接
您可能感興趣的文章:- PHP chop()函數講解
- PHP bin2hex()函數基礎實例講解
- PHP xpath()函數講解
- PHP addcslashes()函數講解
- PHP addslashes()函數講解
- PHP simplexml_load_string()函數實例講解
- PHP simplexml_load_file()函數講解
- PHP simplexml_import_dom()函數講解
- PHP count()函數講解
- PHP chr()函數講解