XML::Stream::Namespace(3) User Contributed Perl Documentation XML::Stream::Namespace(3)NAME
XML::Stream::Namespace - Object to make defining Namespaces easier in
XML::Stream.
SYNOPSIS
XML::Stream::Namespace is a helper package to XML::Stream. It provides a clean way of defining Namespaces for XML::Stream to use when
connecting.
DESCRIPTION
This module allows you to set and read elements from an XML::Stream
Namespace.
METHODS
SetNamespace("mynamespace");
SetXMLNS("http://www.mynamespace.com/xmlns");
SetAttributes(attrib1=>"value1",
attrib2=>"value2");
GetNamespace() returns "mynamespace"
GetXMLNS() returns "http://www.mynamespace.com/xmlns"
GetAttributes() returns a hash ( attrib1=>"value1",attrib2=>"value2")
GetStream() returns the following string:
"xmlns:mynamespace='http://www.nynamespace.com/xmlns'
mynamespace:attrib1='value1'
mynamespace:attrib2='value2'"
EXAMPLES
$myNamespace = new XML::Stream::Namespace("mynamspace");
$myNamespace->SetXMLNS("http://www.mynamespace.org/xmlns");
$myNamespace->SetAttributes(foo=>"bar",
bob=>"vila");
$stream = new XML::Stream;
$stream->Connect(name=>"foo.bar.org",
port=>1234,
namespace=>"foo:bar",
namespaces=>[ $myNamespace ]);
#
# The above Connect will send the following as the opening string
# of the stream to foo.bar.org:1234...
#
# <stream:stream
# xmlns:stream="http://etherx.jabber.org/streams"
# to="foo.bar.org"
# xmlns="foo:bar"
# xmlns:mynamespace="http://www.mynamespace.org/xmlns"
# mynamespace:foo="bar"
# mynamespace:bob="vila">
#
AUTHOR
Written by Ryan Eatmon in February 2000 Idea By Thomas Charron in January of 2000 for http://etherx.jabber.org/streams/
Currently maintained by Darian Anthony Patrick.
COPYRIGHT
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.12.1 2010-01-08 XML::Stream::Namespace(3)
Check Out this Related Man Page
XML::LibXML::Namespace(3) User Contributed Perl Documentation XML::LibXML::Namespace(3)NAME
XML::LibXML::Namespace - XML::LibXML Namespace Implementation
SYNOPSIS
use XML::LibXML;
# Only methods specific to Namespace nodes are listed here,
# see 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();
DESCRIPTION
Namespace nodes are returned by both $element->findnodes('namespace::foo') or by $node->getNamespaces().
The namespace node API is not part of any current DOM API, and so it is quite minimal. It should be noted that namespace nodes are not a
sub class of XML::LibXML::Node, however Namespace nodes act a lot like attribute nodes, and similarly named methods will return what you
would expect if you treated the namespace node as an attribute. Note that in order to fix several inconsistencies between the API and the
documentation, the behavior of some functions have been changed in 1.64.
METHODS
new
my $ns = XML::LibXML::Namespace->new($nsURI);
Creates a new Namespace node. Note that this is not a 'node' as an attribute or an element node. Therefore you can't do call all
XML::LibXML::Node Functions. All functions available for this node are listed below.
Optionally you can pass the prefix to the namespace constructor. If this second parameter is omitted you will create a so called
default namespace. Note, the newly created namespace is not bound to any document or node, therefore you should not expect it to be
available in an existing document.
declaredURI
Returns the URI for this namespace.
declaredPrefix
Returns the prefix for this namespace.
nodeName
print $ns->nodeName();
Returns "xmlns:prefix", where prefix is the prefix for this namespace.
name
print $ns->name();
Alias for nodeName()
getLocalName
$localname = $ns->getLocalName();
Returns the local name of this node as if it were an attribute, that is, the prefix associated with the namespace.
getData
print $ns->getData();
Returns the URI of the namespace, i.e. the value of this node as if it were an attribute.
getValue
print $ns->getValue();
Alias for getData()
value
print $ns->value();
Alias for getData()
getNamespaceURI
$known_uri = $ns->getNamespaceURI();
Returns the string "http://www.w3.org/2000/xmlns/"
getPrefix
$known_prefix = $ns->getPrefix();
Returns the string "xmlns"
AUTHORS
Matt Sergeant, Christian Glahn, Petr Pajas
VERSION
1.70
COPYRIGHT
2001-2007, AxKit.com Ltd.
2002-2006, Christian Glahn.
2006-2009, Petr Pajas.
perl v5.12.1 2009-10-07 XML::LibXML::Namespace(3)