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 — Получает URI пространства имён узла по префиксу
$prefix
): string
Получает URI пространства имён узла на основе префикса
prefix
.
prefix
Префикс пространства имён.
URI пространства имён узла.
Simple way to get the URI of the default namespace:
<?php
$document = new DOMDocument();
$document->load($xml_file);
$uri = $document->documentElement->lookupnamespaceURI(NULL);
?>