Current Location: Home> Function Categories> getNamespaces

getNamespaces

Returns the namespace used in the document.
Name:getNamespaces
Category:Uncategorized
Programming Language:php
One-line Description:Returns the namespace used in the document.

Definition and usage

getNamespaces() function returns the namespace used in the XML document.

Example

Returns all namespaces used in the XML document:

 <?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);
?>

Run the instance

grammar

 SimpleXMLElement :: getNamespaces ( recursive )
parameter describe
Recursive

Optional. Specifies a boolean value.

If TRUE, return all namespaces used in the document;

If FALSE, only the namespace used in the root node is returned.

The default is FALSE.

Similar Functions
Popular Articles