Method: REXML::Attributes#get_attribute_ns
- Defined in:
- lib/rexml/element.rb
#get_attribute_ns(namespace, name) ⇒ Object
The get_attribute_ns
method retrieves a method by its namespace and name. Thus it is possible to reliably identify an attribute even if an XML processor has changed the prefix.
Method contributed by Henrik Martensson
1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 |
# File 'lib/rexml/element.rb', line 1226 def get_attribute_ns(namespace, name) result = nil each_attribute() { |attribute| if name == attribute.name && namespace == attribute.namespace() && ( !namespace.empty? || !attribute..index(':') ) # foo will match xmlns:foo, but only if foo isn't also an attribute result = attribute if !result or !namespace.empty? or !attribute..index(':') end } result end |