Ruby 2.7.0 リファレンスマニュアル > ライブラリ一覧 > rexml/documentライブラリ > REXML::Attributeクラス > prefix

instance method REXML::Attribute#prefix

prefix -> String[permalink][rdoc]

属性の名前空間を返します。


require 'rexml/document'
e = REXML::Element.new( "elns:myelement" )
e.add_attribute( "nsa:a", "aval" )
e.add_attribute( "b", "bval" )
p e.attributes.get_attribute( "a" ).prefix   # -> "nsa"
p e.attributes.get_attribute( "b" ).prefix   # -> "elns"
a = REXML::Attribute.new( "x", "y" )
p a.prefix                                   # -> ""