Simple way to get the URI of the default namespace:
<?php
$document = new DOMDocument();
$document->load($xml_file);
$uri = $document->documentElement->lookupnamespaceURI(NULL);
?>
PHP - Manual: DOMNode::lookupNamespaceUri
2024-11-23
(PHP 5, PHP 7, PHP 8)
DOMNode::lookupNamespaceUri — Gets the namespace URI of the node based on the prefix
$prefix
): string
Gets the namespace URI of the node based on the
prefix
.
prefix
The prefix of the namespace.
The namespace URI of the node.
Simple way to get the URI of the default namespace:
<?php
$document = new DOMDocument();
$document->load($xml_file);
$uri = $document->documentElement->lookupnamespaceURI(NULL);
?>
官方地址:https://www.php.net/manual/en/domnode.lookupnamespaceuri.php