Convert xml attributes to hash { :name => value }
338253
def xml_to_attributes(xml)
			xml.elements["/rsp/attributes"].inject({}) { |h,e| 
				h[e.attributes["name"].to_sym] = e.attributes["value"]
				h 
			}
		end
1170299
def to_h
      Hash[
        attribute_names.
        map do |name| [
          name.to_s.gsub("@","").to_sym,  # key
          (instance_variable_get(name) rescue send(name))] # val
        end
      ]
    end
551658
def attributes
      (@original_attributes||{}).merge(@attributes).keys.inject({}) do |hash, key|
        hash[key] = read_attribute(key)
        hash
      end
    end
636808
def to_xml
      return nil if title.nil? || body.nil?

      xml = ""
      xml << "<d:entry id=\"#{self.id}\" d:title=\"#{self.title}\">\n"
      @index.each do |i|
        xml << "\t<d:index d:value=\"#{i}\" d:title=\"#{title}\" "
        xml << "d:yomi=\"#{yomi}\"" if !self.yomi.nil?
        xml << "/>\n"
      end
      xml << "\t<div>\n"
      xml << "\t\t#{@body}\n"
      xml << "\t</div>\n"
      xml << "</d:entry>\n"

      return xml
    end
559225
def parse_attribute
      ns_id, name_id, val_str_id, flags, val = @io.read(4*5).unpack("V*")
      key = @strings[name_id]
      unless ns_id == 0xFFFFFFFF
        ns = @strings[ns_id] 
        prefix = ns.sub(/.*\//,'')
        unless @ns.include? ns
          @ns << ns
          @doc.root.add_namespace(prefix, ns)
        end
        key = "#{prefix}:#{key}"
      end
      value = convert_value(val_str_id, flags, val)
      return key, value
    end
405566
def attribute_values
      result = element_call { execute_js(:attributeValues, @element) }
      result.keys.each do |key|
        next unless key == key[/[a-zA-Z\-]*/]

        result[key.tr('-', '_').to_sym] = result.delete(key)
      end
      result
    end
1166757
def to_child_hash
      hash = {}
      children { |child| hash[child.name] = child.value }
      return hash
    end
1269927
def to_xml_updates(value)
      return if options[:readonly]
      doc = Nokogiri::XML::Document.new
      if value.is_a?(Array)
        value.each do |sub_value|
          sub_field.to_xml_updates(sub_value) do |field_uri_xml, element_xml|
            element_wrapper = doc.create_element(sub_field.tag_name)
            element_wrapper << element_xml
            yield [
              field_uri_xml,
              element_wrapper
            ]
          end
        end
      elsif value.is_a?(Exchanger::Element)
        value.tag_name = tag_name
        if value.class.elements.keys.include?(:text)
          field = value.class.elements[:text]
          yield [
            field.to_xml_field_uri(value),
            field.to_xml(value)
          ]
        else
          # PhysicalAddress ?
          value.class.elements.each do |name, field|
            yield [
              field.to_xml_field_uri(value),
              field.to_xml(value, :only => [name])
            ]
          end
        end
      else # String, Integer, Boolean, ...
        yield [
          self.to_xml_field_uri(value),
          self.to_xml(value)
        ]
      end
    end
915212
def parse_special_attributes(raw_attrs)
      return {} if raw_attrs.blank?
      items = raw_attrs.split(/\s+/)

      id      = items.select { |i| i =~ /^#.+/ }.first.gsub('#', '')
      classes = items.select { |i| i =~ /^\..+/ }.map { |c| c.gsub('.', '') }
      attrs   = Hash[items.select { |i| i.include?('=') }.map { |i| i.split('=') }]

      attrs.merge({
        'id' => id,
        'class' => classes.join(' ')
      })
    end
741145
def names_by_value(a)
      a = @data[a] if a.is_a?(String) || a.is_a?(Symbol)
      Hash[ a.map { |i| i.reverse } ]
    end
924480
def string_to_hash(markup)
      options = {}

      if match = markup.match(Syntax)
        markup.scan(TagAttributes) do |key, value|
          options[key.to_sym] = value.gsub(/\A"|"\z/, "")
        end
      end

      options
    end
634372
def to_hash()
      ret_hash = {}
      self.class.json_attributes.each do |attrib|
        ret_hash[attrib] = self.send(attrib.to_s.underscore)
      end
      return ret_hash
    end
437633
def serialize!(attributes)
      unless attributes.nil?
        attributes.each do |key, value|
          key = "id" if key == "_id"
          self.send("#{key}=", (value.dup rescue value))
        end
      end

      self.dup
    end
484275
def to_hash
      doc = ::Nokogiri::XML( self.response )
      hash = {}
      doc.at_css("Response").element_children.each do |attribute|
        hash[attribute.name.underscore.to_sym] = attribute.inner_text
      end
      hash[:valid] = doc.at_css("Response")['valid']
      hash
    end
701041
def synced_attributes_as_hash(attributes)
      return attributes if attributes.is_a?(Hash)
      Hash[Array.wrap(attributes).map { |name| [name, name] }]
    end
691504
def to_output_hash
      HASH_SCHEMA.schema(
        map { |attr| [attr.key, attr.to_read_type] }.to_h
      )
    end
1231331
def to_hash
      stringified_params = Hash[parameters.map { |key, val| [key.to_s, val] }]
      base_hash.merge(stringified_params)
    end