1XML::LibXML::Namespace(U3s)er Contributed Perl DocumentatXiMoLn::LibXML::Namespace(3)
2
3
4
6 XML::LibXML::Namespace - XML::LibXML Namespace Implementation
7
9 use XML::LibXML;
10 # Only methods specific to Namespace nodes are listed here,
11 # see the XML::LibXML::Node manpage for other methods
12
13 my $ns = XML::LibXML::Namespace->new($nsURI);
14 print $ns->nodeName();
15 print $ns->name();
16 $localname = $ns->getLocalName();
17 print $ns->getData();
18 print $ns->getValue();
19 print $ns->value();
20 $known_uri = $ns->getNamespaceURI();
21 $known_prefix = $ns->getPrefix();
22 $key = $ns->unique_key();
23
25 Namespace nodes are returned by both
26 $element->findnodes('namespace::foo') or by $node->getNamespaces().
27
28 The namespace node API is not part of any current DOM API, and so it is
29 quite minimal. It should be noted that namespace nodes are not a sub
30 class of XML::LibXML::Node, however Namespace nodes act a lot like
31 attribute nodes, and similarly named methods will return what you would
32 expect if you treated the namespace node as an attribute. Note that in
33 order to fix several inconsistencies between the API and the
34 documentation, the behavior of some functions have been changed in
35 1.64.
36
38 new
39 my $ns = XML::LibXML::Namespace->new($nsURI);
40
41 Creates a new Namespace node. Note that this is not a 'node' as an
42 attribute or an element node. Therefore you can't do call all
43 XML::LibXML::Node Functions. All functions available for this node
44 are listed below.
45
46 Optionally you can pass the prefix to the namespace constructor. If
47 this second parameter is omitted you will create a so called
48 default namespace. Note, the newly created namespace is not bound
49 to any document or node, therefore you should not expect it to be
50 available in an existing document.
51
52 declaredURI
53 Returns the URI for this namespace.
54
55 declaredPrefix
56 Returns the prefix for this namespace.
57
58 nodeName
59 print $ns->nodeName();
60
61 Returns "xmlns:prefix", where prefix is the prefix for this
62 namespace.
63
64 name
65 print $ns->name();
66
67 Alias for nodeName()
68
69 getLocalName
70 $localname = $ns->getLocalName();
71
72 Returns the local name of this node as if it were an attribute,
73 that is, the prefix associated with the namespace.
74
75 getData
76 print $ns->getData();
77
78 Returns the URI of the namespace, i.e. the value of this node as if
79 it were an attribute.
80
81 getValue
82 print $ns->getValue();
83
84 Alias for getData()
85
86 value
87 print $ns->value();
88
89 Alias for getData()
90
91 getNamespaceURI
92 $known_uri = $ns->getNamespaceURI();
93
94 Returns the string "http://www.w3.org/2000/xmlns/"
95
96 getPrefix
97 $known_prefix = $ns->getPrefix();
98
99 Returns the string "xmlns"
100
101 unique_key
102 $key = $ns->unique_key();
103
104 This method returns a key guaranteed to be unique for this
105 namespace, and to always be the same value for this namespace. Two
106 namespace objects return the same key if and only if they have the
107 same prefix and the same URI. The returned key value is useful as a
108 key in hashes.
109
111 Matt Sergeant, Christian Glahn, Petr Pajas
112
114 2.0207
115
117 2001-2007, AxKit.com Ltd.
118
119 2002-2006, Christian Glahn.
120
121 2006-2009, Petr Pajas.
122
124 This program is free software; you can redistribute it and/or modify it
125 under the same terms as Perl itself.
126
127
128
129perl v5.32.1 2021-04-19 XML::LibXML::Namespace(3)