Method: CoreLibrary::XmlHelper.from_element_to_hash

Defined in:
lib/apimatic-core/utilities/xml_helper.rb

.from_element_to_hash(parent, name, clazz, datetime_format: nil) ⇒ Object

Converts element to hash.



230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/apimatic-core/utilities/xml_helper.rb', line 230

def from_element_to_hash(parent, name, clazz,
                         datetime_format: nil)
  entries = parent.at_xpath(name)
  return nil if entries.nil? || entries.children.nil?

  hash = {}

  entries.element_children.each do |element|
    hash[element.name] = convert(element.text, clazz, datetime_format)
  end

  hash
end