class REXML::Element
def add_namespace( prefix, uri=nil )
e.namespaces # => {"xmlns"=>"bar", "baz"=>"bat"}
e.add_namespace('baz', 'bat')
adds a namespace using both arguments:
With both arguments +prefix+ and +uri+ given,
e.namespaces # => {"xmlns"=>"bar"}
e.add_namespace('bar')
e = REXML::Element.new('foo')
adds a namespace using the given +prefix+ and the namespace URI:
With the single argument +prefix+,
Adds a namespace to the element; returns +self+.
add_namespace(prefix, uri = nil) -> self
:call-seq:
def add_namespace( prefix, uri=nil ) unless uri @attributes["xmlns"] = prefix else prefix = "xmlns:#{prefix}" unless prefix =~ /^xmlns:/ @attributes[ prefix ] = uri end self end