略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: DOMNode::lookupNamespaceUri

2024-12-23

DOMNode::lookupNamespaceUri

(PHP 5, PHP 7, PHP 8)

DOMNode::lookupNamespaceUri Gets the namespace URI of the node based on the prefix

说明

public DOMNode::lookupNamespaceUri(string $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.

参见

add a noteadd a note

User Contributed Notes 2 notes

up
8
lewar
15 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
12 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).

官方地址:https://www.php.net/manual/en/domnode.lookupnamespaceuri.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3