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 ใซๅบใฅใใฆใ
ใใผใใฎๅๅ็ฉบ้ URI ใๅๅพใใพใใ
prefix
ๆขใๅๅ็ฉบ้ใฎใใฌใใฃใใฏในใ
null ใๆๅฎใใๅ ดๅใใใใฉใซใใฎๅๅ็ฉบ้URIใ่ฟใใพใใ
ไฝใใๅญๅจใใๅ ดๅใซ้ใใพใใ
้ข้ฃใใๅๅ็ฉบ้ URI ใ่ฟใใพใใ
่ฆใคใใใชใใฃใๅ ดๅใฏ null ใ่ฟใใพใใ
Simple way to get the URI of the default namespace:
<?php
$document = new DOMDocument();
$document->load($xml_file);
$uri = $document->documentElement->lookupnamespaceURI(NULL);
?>