©
本文檔使用 php中文網手册 發布
(PHP 5, PHP 7)
DOMNode::lookupNamespaceURI — Gets the namespace URI of the node based on the prefix
$prefix
)
Gets the namespace URI of the node based on the
prefix
.
prefix
The prefix of the namespace.
The namespace URI of the node.
[#1] _ michael [2010-04-30 14:22:56]
You have to pass *null* to lookupNamespaceURI if you want to read the default namespace. Passing an empty string doesn't work - even though the documentation says that lookupNamespaceURI takes a string as argument (and null would just be converted to an empty string).
[#2] lewar [2007-06-05 05:20:22]
Simple way to get the URI of the default namespace:
<?php
$document = new DOMDocument();
$document->load($xml_file);
$uri = $document->documentElement->lookupnamespaceURI(NULL);
?>