CakeFest 2024: The Official CakePHP Conference

DOMNode::lookupNamespaceURI

(PHP 5, PHP 7, PHP 8)

DOMNode::lookupNamespaceURI プレフィックスに基づいて、ノードの名前空間 URI を取得する

説明

public DOMNode::lookupNamespaceURI(?string $prefix): ?string

prefix に基づいて、 ノードの名前空間 URI を取得します。

パラメータ

prefix

探す名前空間のプレフィックス。 null を指定した場合、デフォルトの名前空間URIを返します。 但し、存在する場合に限ります。

戻り値

関連する名前空間 URI を返します。 見つからなかった場合は null を返します。

参考

  • DOMNode::lookupPrefix() - 名前空間 URI に基づいて、ノードの名前空間プレフィックスを取得する

add a note

User Contributed Notes 2 notes

up
7
lewar
16 years ago
Simple way to get the URI of the default namespace:

<?php
$document
= new DOMDocument();
$document->load($xml_file);
$uri = $document->documentElement->lookupnamespaceURI(NULL);
?>
up
-5
_ michael
13 years ago
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).
To Top