public Method

Base.to_xml(options={})

Contents:

A method to convert the the resource to an XML string.

Options

The options parameter is handed off to the to_xml method on each attribute, so it has the same options as the to_xml methods in ActiveSupport.

indent:Set the indent level for the XML output (default is +2+).
dasherize:Boolean option to determine whether or not element names should replace underscores with dashes (default is false).
skip_instruct:Toggle skipping the +instruct!+ call on the XML builder that generates the XML declaration (default is false).

Examples

my_group = SubsidiaryGroup.find(:first)
my_group.to_xml
# => <?xml version="1.0" encoding="UTF-8"?>
#    <subsidiary_group> [...] </subsidiary_group>

my_group.to_xml(:dasherize => true)
# => <?xml version="1.0" encoding="UTF-8"?>
#    <subsidiary-group> [...] </subsidiary-group>

my_group.to_xml(:skip_instruct => true)
# => <subsidiary_group> [...] </subsidiary_group>

Source Code

# File active_resource/base.rb, line 721
def to_xml(options={})
  attributes.to_xml({:root => self.class.element_name}.merge(options))
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.