XML::Stream::Namespace - Object to make defining Namespaces easier in XML::Stream.
| Use Case | Command | Description |
|---|---|---|
| Create a new namespace object | XML::Stream::Namespace->new("prefix") | Creates a namespace object with a given prefix. |
| Set the XML namespace URI | $ns->SetXMLNS("http://example.com/xmlns") | Sets the URI for the namespace. |
| Set additional attributes | $ns->SetAttributes(attrib1=>"value1") | Sets additional XML attributes for the namespace. |
| Use namespace in stream connection | $stream->Connect(namespace=>"foo:bar", namespaces=>[$ns]) | Pass namespace object(s) to Connect to include in the stream opening tag. |
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.
This module allows you to set and read elements from an XML::Stream Namespace.
SetNamespace($namespace) — Sets the namespace prefix.SetXMLNS($uri) — Sets the XML namespace URI.SetAttributes(%attributes) — Sets additional attributes (key-value pairs) for the namespace.GetNamespace() — Returns the namespace prefix string.GetXMLNS() — Returns the XML namespace URI.GetAttributes() — Returns a hash of attributes.GetStream() — Returns the XML namespace declaration string, e.g., xmlns:mynamespace='http://...' with attributes.$myNamespace = XML::Stream::Namespace->new("mynamspace");
$myNamespace->SetXMLNS("http://www.mynamespace.org/xmlns");
$myNamespace->SetAttributes(foo=>"bar",
bob=>"vila");
$stream = XML::Stream->new;
$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">
#
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 (C) 1998-2004 Jabber Software Foundation http://jabber.org/
This module licensed under the LGPL, version 2.1.
Generated by phpman v4.9.29 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-22 00:33 @2600:1f28:365:80b0:d8a5:c3c6:bf94:28c0
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format