{"id":19358650,"url":"https://github.com/jasonlittleton24/activerecordmodel-serializers-xml","last_synced_at":"2026-04-21T10:04:43.683Z","repository":{"id":195684204,"uuid":"693436849","full_name":"jasonlittleton24/ActiveRecordModel-Serializers-XML","owner":"jasonlittleton24","description":"This gem provides XML serialization for your Active Model objects and Active Record models.","archived":false,"fork":false,"pushed_at":"2023-09-19T03:11:40.000Z","size":60,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-24T11:50:41.662Z","etag":null,"topics":["ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jasonlittleton24.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-19T03:08:45.000Z","updated_at":"2023-09-19T03:09:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"1e70c4ea-8c40-4c68-b02e-00b2b22d89a5","html_url":"https://github.com/jasonlittleton24/ActiveRecordModel-Serializers-XML","commit_stats":null,"previous_names":["jamesmarquez0508/activerecordmodel-serializers-xml","jasonlittleton24/activerecordmodel-serializers-xml"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jasonlittleton24/ActiveRecordModel-Serializers-XML","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonlittleton24%2FActiveRecordModel-Serializers-XML","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonlittleton24%2FActiveRecordModel-Serializers-XML/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonlittleton24%2FActiveRecordModel-Serializers-XML/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonlittleton24%2FActiveRecordModel-Serializers-XML/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jasonlittleton24","download_url":"https://codeload.github.com/jasonlittleton24/ActiveRecordModel-Serializers-XML/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonlittleton24%2FActiveRecordModel-Serializers-XML/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263140794,"owners_count":23419954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby","ruby-on-rails"],"created_at":"2024-11-10T07:12:34.289Z","updated_at":"2026-04-21T10:04:43.644Z","avatar_url":"https://github.com/jasonlittleton24.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActiveModel::Serializers::Xml\n\nThis gem provides XML serialization for your Active Model objects and Active Record models.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'activemodel-serializers-xml'\n```\n\nAnd then execute:\n\n```\n$ bundle\n```\n\nOr install it yourself as:\n\n```\n$ gem install activemodel-serializers-xml\n```\n\n## Usage\n\n### ActiveModel::Serializers::Xml\n\nTo use the `ActiveModel::Serializers::Xml` you only need to change from\n`ActiveModel::Serialization` to `ActiveModel::Serializers::Xml`.\n\n```ruby\nclass Person\n  include ActiveModel::Serializers::Xml\n\n  attr_accessor :name\n\n  def attributes\n    {'name' =\u003e nil}\n  end\nend\n```\n\nWith the `to_xml` you have an XML representing the model.\n\n```ruby\nperson = Person.new\nperson.to_xml # =\u003e \"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cperson\u003e\\n  \u003cname nil=\\\"true\\\"/\u003e\\n\u003c/person\u003e\\n\"\nperson.name = \"Bob\"\nperson.to_xml # =\u003e \"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cperson\u003e\\n  \u003cname\u003eBob\u003c/name\u003e\\n\u003c/person\u003e\\n\"\n```\n\nFrom an XML string you define the attributes of the model.\nYou need to have the `attributes=` method defined on your class:\n\n```ruby\nclass Person\n  include ActiveModel::Serializers::Xml\n\n  attr_accessor :name\n\n  def attributes=(hash)\n    hash.each do |key, value|\n      send(\"#{key}=\", value)\n    end\n  end\n\n  def attributes\n    {'name' =\u003e nil}\n  end\nend\n```\n\nNow it is possible to create an instance of person and set the attributes using `from_xml`.\n\n```ruby\nxml = { name: 'Bob' }.to_xml\nperson = Person.new\nperson.from_xml(xml) # =\u003e #\u003cPerson:0x00000100c773f0 @name=\"Bob\"\u003e\nperson.name          # =\u003e \"Bob\"\n```\n### ActiveRecord::XmlSerializer\n\nThis gem also provides serialization to XML for Active Record.\n\nPlease see ActiveRecord::Serialization#to_xml for more information.\n\n## Contributing to ActiveModel::Serializers::Xml\n\nActiveModel::Serializers::Xml is work of many contributors. You're encouraged to submit pull requests, propose features and discuss issues.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonlittleton24%2Factiverecordmodel-serializers-xml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjasonlittleton24%2Factiverecordmodel-serializers-xml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonlittleton24%2Factiverecordmodel-serializers-xml/lists"}