Simple way to get the URI of the default namespace:
<?php
$document = new DOMDocument();
$document->load($xml_file);
$uri = $document->documentElement->lookupnamespaceURI(NULL);
?>
(PHP 5, PHP 7, PHP 8)
DOMNode::lookupNamespaceURI — Gets the namespace URI of the node based on the prefix
Gets the namespace URI of the node based on the
prefix
.
prefix
The prefix to look for. If this parameter is null
, the method will return the default namespace URI, if any.
Returns the associated namespace URI or null
if none is found.
Simple way to get the URI of the default namespace:
<?php
$document = new DOMDocument();
$document->load($xml_file);
$uri = $document->documentElement->lookupnamespaceURI(NULL);
?>