# perldoc > XML::LibXML::Namespace

---
type: CommandReference
command: XML::LibXML::Namespace
mode: perldoc
section: ""
source: perldoc
---

## Quick Reference

- `XML::LibXML::Namespace->new($nsURI)` — create a new namespace node (optionally with prefix)
- `$ns->nodeName()` — returns "xmlns:prefix"
- `$ns->getLocalName()` — returns the prefix associated with the namespace
- `$ns->getData()` — returns the URI of the namespace
- `$ns->getValue()` — alias for `getData()`
- `$ns->getNamespaceURI()` — returns `"http://www.w3.org/2000/xmlns/"`
- `$ns->getPrefix()` — returns `"xmlns"`
- `$ns->unique_key()` — returns a unique, repeatable key for the namespace (prefix + URI)

## Name

XML::LibXML::Namespace - XML::LibXML Namespace Implementation

## Synopsis

perl
use XML::LibXML;
# Only methods specific to Namespace nodes are listed here,
# see the XML::LibXML::Node manpage for other methods

my $ns = XML::LibXML::Namespace->new($nsURI);
print $ns->nodeName();
print $ns->name();
$localname = $ns->getLocalName();
print $ns->getData();
print $ns->getValue();
print $ns->value();
$known_uri = $ns->getNamespaceURI();
$known_prefix = $ns->getPrefix();
$key = $ns->unique_key();
## Description

Namespace nodes are returned by `$element->findnodes('namespace::foo')` or by `$node->getNamespaces()`. The namespace node API is minimal and is not part of any current DOM API. Namespace nodes are **not** a subclass of `XML::LibXML::Node`, but they act like attribute nodes. Note that behavior of some functions changed in version 1.64 to fix inconsistencies.

## Methods

- `new($nsURI)` — Creates a new namespace node. Optionally pass a prefix; if omitted, a default namespace is created. The new namespace is not bound to any document or node.
- `declaredURI()` — Returns the URI for this namespace.
- `declaredPrefix()` — Returns the prefix for this namespace.
- `nodeName()` — Returns `"xmlns:prefix"`, where prefix is the namespace prefix.
- `name()` — Alias for `nodeName()`.
- `getLocalName()` — Returns the local name as if it were an attribute (i.e., the prefix associated with the namespace).
- `getData()` — Returns the URI of the namespace (the value of this node as if it were an attribute).
- `getValue()` — Alias for `getData()`.
- `value()` — Alias for `getData()`.
- `getNamespaceURI()` — Returns the string `"http://www.w3.org/2000/xmlns/"`.
- `getPrefix()` — Returns the string `"xmlns"`.
- `unique_key()` — Returns a key guaranteed to be unique for this namespace and always the same value for the same namespace. Two namespace objects return the same key if and only if they have the same prefix and the same URI. Useful as a key in hashes.

## See Also

- [XML::LibXML](https://metacpan.org/pod/XML::LibXML)
- [XML::LibXML::Node](https://metacpan.org/pod/XML::LibXML::Node)
- [XML::LibXML::Document](https://metacpan.org/pod/XML::LibXML::Document)