From: "Volkmann, Mark" <Mark.Volkmann / AGEDWARDS.com>
Subject: REXML namespace support
Date: Fri, 27 Sep 2002 22:45:45 +0900
Message-ID: <89539780CB9BD51182270002A5897DF602C6D670 / hqempn04.agedwards.com>

> Is there an easy way in REXML to get the namespace that is associated with a
> given prefix?

You can use REXML::Element#namespace if you are using a-la DOM API.

----------Example-----------------
require 'rexml/document'

xml = <<XML
<?xml version='1.0'?>
<a xmlns:fuga='foo'>
 <b>
  <c xmlns:fuga='hoge'/>
 </b>
 <d xmlns:fuga='bar'/>
</a>
XML

doc = REXML::Document.new(xml)

p doc.root.namespace("fuga")
p doc.elements["/a/b"].namespace("fuga")
p doc.elements["/a/b/c"].namespace("fuga")
p doc.elements["/a/d"].namespace("fuga")
----------Example-----------------

----------Output------------------
"foo"
"foo"
"hoge"
"bar"
----------Output------------------

======================
Kouhei Sutou
kou / cneti.net