$xml = simplexml_load_file('file.xml'); $namespaces = $xml->getDocNamespaces(); print_r($namespaces);
$xml = new SimpleXMLElement('In this example, we are not using any external package library as SimpleXMLElement is a built-in PHP class.', LIBXML_NOERROR | LIBXML_ERR_NONE | LIBXML_NOWARNING); $xml->addAttribute('xmlns', 'http://example.com'); $namespaces = $xml->getDocNamespaces(); print_r($namespaces);