Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > rexml/documentライブラリ > REXML::Attributesクラス > namespaces
namespaces -> { String => String }[permalink][rdoc]self の中で宣言されている名前空間の集合を返します。
返り値は名前空間の prefix をキーとし、URI を値とする Hash を返します。
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root xmlns:foo="http://example.org/foo"
      xmlns:bar="http://example.org/bar">
  <a foo:att='1' bar:att='2' att='<'/>
</root>
EOS
a = doc.get_elements("/root/a").first
p doc.root.attributes.namespaces
# => {"foo"=>"http://example.org/foo", "bar"=>"http://example.org/bar"}
p a.attributes.namespaces
# => {}