method

namespace

v1_9_1_378 - Show latest stable - Class: REXML::Element
namespace(prefix=nil)
public

Evalutas to the URI for a prefix, or the empty string if no such namespace is declared for this element. Evaluates recursively for ancestors. Returns the default namespace, if there is one.

prefix

the prefix to search for. If not supplied, returns the default namespace if one exists

Returns

the namespace URI as a String, or nil if no such namespace exists. If the namespace is undefined, returns an empty string

doc = Document.new(“<a xmlns=‘1’ xmlns:y=‘2’><c xmlns:z=‘3’/>”) b = doc.elements[‘//b’] b.namespace # -> ‘1’ b.namespace(“y”) # -> ‘2’