今天小編就爲大家分享一篇關於PHP getDocNamespaces()函數講解,小編覺得內容挺不錯的,現在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
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); ?>
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對神馬文庫的支持。如果你想了解更多相關內容請查看下面相關鏈接