Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP getNamespaces() Function

PHP getNamespaces() Function

PHP SimpleXML Reference Manual PHP SimpleXML Reference Manual

Example

Return the namespaces used in an XML document:

Volvo

BMW

Saab

XML;

$sxe=new SimpleXMLElement($xml);

$ns=$sxe->getNamespaces(true);

var_dump($ns);

?>

Run Example »


Definition and Usage

The getNamespaces() function returns the namespaces used in an XML document.


Syntax

getNamespaces(

recursive

);

Parameters Description
recursive Optional. Specifies a boolean. If TRUE, returns all namespaces declared in all parent and child nodes. If FALSE, only returns the namespaces declared in the root node. Default is FALSE.

Technical Details

Return Value: Returns an array of namespace names with their associated URIs.
PHP Version: 5.1.2+

PHP SimpleXML Reference Manual PHP SimpleXML Reference Manual