demo_func_simplexml_getdocnamespaces2.php:
<!DOCTYPE html> <html> <body> <?php $xml=<<<XML <?xml version="1.0" standalone="yes"?> <cars xmlns:c="https://begtut.com/ns"> <c:car id="1">Volvo</c:car> <c:car id="2">BMW</c:car> <c:car id="3" a:country="Sweden" xmlns:a="https://begtut.com/country">Saab</c:car> </cars> XML; $sxe=new SimpleXMLElement($xml); $ns=$sxe->getDocNamespaces(TRUE); var_dump($ns); ?> </body> </html>