getNamespaces
返回文檔中使用的命名空間。
getNamespaces()
函數返回XML 文檔中使用的命名空間。
返回XML 文檔中使用的所有命名空間:
<?php $xml = << < XML < ? xml version = "1.0" standalone = "yes" ?> < cars xmlns: c = " http://gitbox.net/ns " xmlns: a = " http://gitbox.net/country " > < 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->getNamespaces(true); var_dump($ns); ?>
運行實例
SimpleXMLElement :: getNamespaces ( recursive )
參數 | 描述 |
---|---|
recursive |
可選。指定布爾值。 如果為TRUE,則返回文檔中使用的所有命名空間; 如果為FALSE,則僅返回根節點中使用的命名空間。 默認為FALSE。 |