• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • DOMNode::lookupNamespaceUri()

    (PHP 5, PHP 7)

    Gets the namespace URI of the node based on the prefix

    说明

    publicDOMNode::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.

    参见

    • DOMNode::lookupPrefix() Gets the namespace prefix of the node based on the namespace URI
    Simple way to get the URI of the default namespace:
    <?php
      $document = new DOMDocument();
      $document->load($xml_file);
      $uri = $document->documentElement->lookupnamespaceURI(NULL);
    ?>
    
    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).