Each MultiXml parser is expected to parse an XML document into a Hash. The conversion rules are:
| REQUIREMENT_MAP | = | [ ['ox', :ox], ['libxml', :libxml], ['nokogiri', :nokogiri], ['rexml/document', :rexml], ['oga', :oga], ].freeze |
| CONTENT_ROOT | = | '__content__'.freeze unless defined?(CONTENT_ROOT) |
| PARSING | = | { 'symbol' => proc { |symbol| symbol.to_sym }, 'date' => proc { |date| Date.parse(date) }, 'datetime' => datetime_proc, 'dateTime' => datetime_proc, 'integer' => proc { |integer| integer.to_i }, 'float' => float_proc, 'double' => float_proc, 'decimal' => proc { |number| BigDecimal(number) }, 'boolean' => proc { |boolean| !%w(0 false).include?(boolean.strip) }, 'string' => proc { |string| string.to_s }, 'yaml' => proc { |yaml| YAML.load(yaml) rescue yaml }, # rubocop:disable RescueModifier 'base64Binary' => proc { |binary| ::Base64.decode64(binary) }, 'binary' => proc { |binary, entity| parse_binary(binary, entity) }, 'file' => proc { |file, entity| parse_file(file, entity) }, }.freeze |
| TYPE_NAMES | = | { 'Symbol' => 'symbol', 'Integer' => 'integer', 'BigDecimal' => 'decimal', 'Float' => 'float', 'TrueClass' => 'boolean', 'FalseClass' => 'boolean', 'Date' => 'date', 'DateTime' => 'datetime', 'Time' => 'datetime', 'Array' => 'array', 'Hash' => 'hash', }.freeze |
| DISALLOWED_XML_TYPES | = | %w(symbol yaml).freeze |
| DEFAULT_OPTIONS | = | { :typecast_xml_value => true, :disallowed_types => DISALLOWED_XML_TYPES, :symbolize_keys => false, }.freeze |
The default parser based on what you currently have loaded and installed. First checks to see if any parsers are already loaded, then checks to see which are installed if none are loaded.
Parse an XML string or IO into Ruby.
Options
| :symbolize_keys : | If true, will use symbols instead of strings for the keys. |
| :disallowed_types : | Types to disallow from being typecasted. Defaults to `[‘yaml’, ‘symbol’]`. Use `[]` to allow all types. |
| :typecast_xml_value : | If true, won‘t typecast values for parsed document |
Set the XML parser utilizing a symbol, string, or class. Supported by default are: