Returns the namespace used in the XML document:
<?php$xml=<<<XML<?xml version="1.0" standalone="yes"?><cars xmlns:c="http://w3cschool.cc/ns" xmlns:a="http:/ /w3cschool.cc/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);?>The getNamespaces() function returns the namespaces used in the XML document.
getNamespaces( recursive );
parameter | describe |
---|---|
recursive | Optional. Specifies a boolean value. If TRUE, returns all namespaces declared in all parent and child nodes. If the value is FALSE, only namespaces declared in the root node are returned. The default is FALSE. |
Return value: | Returns an array of namespace names with associated URIs. |
---|---|
PHP version: | 5.1.2+ |