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
prefix
に基づいて、
ノードの名前空間 URI を取得します。
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);
?>