method
attribute
v2_1_10 -
Show latest stable
- Class:
REXML::Element
attribute( name, namespace=nil )public
# File lib/rexml/element.rb, line 553
def attribute( name, namespace=nil )
prefix = nil
if namespaces.respond_to? :key
prefix = namespaces.key(namespace) if namespace
else
prefix = namespaces.index(namespace) if namespace
end
prefix = nil if prefix == 'xmlns'
ret_val =
attributes.get_attribute( "#{prefix ? prefix + ':' : ''}#{name}" )
return ret_val unless ret_val.nil?
return nil if prefix.nil?
# now check that prefix'es namespace is not the same as the
# default namespace
return nil unless ( namespaces[ prefix ] == namespaces[ 'xmlns' ] )
attributes.get_attribute( name )
end Related methods
- Instance methods
- add_attribute
- add_attributes
- add_element
- add_namespace
- add_text
- attribute
- cdatas
- clone
- comments
- delete_attribute
- delete_element
- delete_namespace
- document
- each_element
- each_element_with_attribute
- each_element_with_text
- get_elements
- get_text
- has_attributes?
- has_elements?
- has_text?
- ignore_whitespace_nodes
- inspect
- instructions
- namespace
- namespaces
- next_element
- node_type
- prefixes
- previous_element
- raw
- root
- root_node
- text
- text=
- texts
- whitespace
- write
- xpath
- Class methods
- new
- Private methods
-
__to_xpath_helper -
each_with_something