PHP getDocNamespaces()函數(shù)講解
PHP getDocNamespaces() 函數(shù)
實(shí)例
返回 XML 文檔的根節(jié)點(diǎn)中聲明的命名空間:
<?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()函數(shù)返回 XML 文檔中聲明的命名空間。
語(yǔ)法
getDocNamespaces( _recursive_ , _from_root_ );


實(shí)例 1
返回 XML 文檔的父節(jié)點(diǎn)和子節(jié)點(diǎn)中聲明的所有命名空間:
<?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); ?>
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接
相關(guān)文章
PHP strstr 函數(shù)判斷字符串是否否存在的實(shí)例代碼
我們經(jīng)常使用strstr函數(shù)用來(lái)判斷某個(gè)字符串中是否包含了制定字符串,如果未找到所搜索的字符串,則返回 false,有責(zé)返回從匹配點(diǎn)開(kāi)始的字符串2013-09-09
Mysql的GROUP_CONCAT()函數(shù)使用方法
GROUP_CONCAT語(yǔ)法與實(shí)例代碼2008-03-03
創(chuàng)造世界上最簡(jiǎn)單的 PHP 開(kāi)發(fā)模式
這篇文章主要介紹了創(chuàng)造世界上最簡(jiǎn)單的 PHP 開(kāi)發(fā)模式2006-12-12

