Module: ActiveModel::Serializers::Xml

### Home Classes Methods

### In Files

- lib/active_model/serializers/xml.rb

### Methods

- #from_xml
- #to_xml

### Included Modules

- ActiveModel::Serialization

### Class/Module Index

Quicksearch

- ActiveModel
- ActiveModel::AttributeMethods
- ActiveModel::AttributeMethods::ClassMethods
- ActiveModel::AttributeMethods::ClassMethods::AttributeMethodMatcher
- ActiveModel::BlockValidator
- ActiveModel::Callbacks
- ActiveModel::Conversion
- ActiveModel::Dirty
- ActiveModel::EachValidator
- ActiveModel::Errors
- ActiveModel::Lint
- ActiveModel::Lint::Tests
- ActiveModel::MassAssignmentSecurity
- ActiveModel::MassAssignmentSecurity::BlackList
- ActiveModel::MassAssignmentSecurity::ClassMethods
- ActiveModel::MassAssignmentSecurity::Error
- ActiveModel::MassAssignmentSecurity::LoggerSanitizer
- ActiveModel::MassAssignmentSecurity::PermissionSet
- ActiveModel::MassAssignmentSecurity::Sanitizer
- ActiveModel::MassAssignmentSecurity::StrictSanitizer
- ActiveModel::MassAssignmentSecurity::WhiteList
- ActiveModel::MissingAttributeError
- ActiveModel::Name
- ActiveModel::Naming
- ActiveModel::Observer
- ActiveModel::ObserverArray
- ActiveModel::Observing
- ActiveModel::Observing::ClassMethods
- ActiveModel::SecurePassword
- ActiveModel::SecurePassword::ClassMethods
- ActiveModel::SecurePassword::InstanceMethodsOnActivation
- ActiveModel::Serialization
- ActiveModel::Serializers
- ActiveModel::Serializers::JSON
- ActiveModel::Serializers::Xml
- ActiveModel::StrictValidationFailed
- ActiveModel::Translation
- ActiveModel::Validations
- ActiveModel::Validations::AcceptanceValidator
- ActiveModel::Validations::Callbacks
- ActiveModel::Validations::Callbacks::ClassMethods
- ActiveModel::Validations::ClassMethods
- ActiveModel::Validations::ConfirmationValidator
- ActiveModel::Validations::ExclusionValidator
- ActiveModel::Validations::FormatValidator
- ActiveModel::Validations::HelperMethods
- ActiveModel::Validations::InclusionValidator
- ActiveModel::Validations::LengthValidator
- ActiveModel::Validations::NumericalityValidator
- ActiveModel::Validations::PresenceValidator
- ActiveModel::Validations::WithValidator
- ActiveModel::Validator

No matching classes.

# ActiveModel::Serializers::Xml

## Active Model XML Serializer

### Public Instance Methods

from_xml(xml) click to toggle source

    # File lib/active_model/serializers/xml.rb, line 198
    def from_xml(xml)
      self.attributes = Hash.from_xml(xml).values.first
      self
    end

to_xml(options = {}, &block) click to toggle source

Returns XML representing the model. Configuration can be passed through `options`.

Without any `options`, the returned XML string will include all the model's attributes. For example:

    user = User.find(1)
    user.to_xml

    <?xml version="1.0" encoding="UTF-8"?>
    <user>
      <id type="integer">1</id>
      <name>David</name>
      <age type="integer">16</age>
      <created-at type="datetime">2011-01-30T22:29:23Z</created-at>
    </user>

The `:only` and `:except` options can be used to limit the attributes included, and work similar to the `attributes` method.

To include the result of some method calls on the model use `:methods`.

To include associations use `:include`.

For further documentation see activerecord/lib/active_record/serializers/xml_serializer.xml.

    # File lib/active_model/serializers/xml.rb, line 194
    def to_xml(options = {}, &block)
      Serializer.new(self, options).serialize(&block)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.