Sha256: 73fb9c48dcf0b5e5ad88b64af6229dace67ce89caea95fb9ac27f17fb0ac2c9a

Contents?: true

Size: 597 Bytes

Versions: 22

Compression:

Stored size: 597 Bytes

Contents

require 'rexml/document'

##
# exports contacts in xml format

class Blackbook::Exporter::Xml < Blackbook::Exporter::Base

  ##
  # contacts are an array of hashes that are contacts and returns xml

  def export( contacts )
    doc = REXML::Document.new
    doc << REXML::XMLDecl.new
    
    root = doc.add_element 'contacts'
    contacts.each do |contact|
      el = root.add_element 'contact'
      name = el.add_element 'name' 
      name.text = contact[:name]
      
      el.add_element('email').text = contact[:email]
    end
    
    doc.to_s
  end
  
  Blackbook.register(:xml, self)
end

Version data entries

22 entries across 22 versions & 5 rubygems

Version Path
alexjp-blackbook_csv-1.0.5 lib/blackbook/exporter/xml.rb
alexjp-blackbook_csv-3.0.1 lib/blackbook/exporter/xml.rb
alexjp-blackbook_csv-3.0.2 lib/blackbook/exporter/xml.rb
bcardarella-blackbook-1.0.10 lib/blackbook/exporter/xml.rb
bcardarella-blackbook-1.0.11 lib/blackbook/exporter/xml.rb
bcardarella-blackbook-1.0.7 lib/blackbook/exporter/xml.rb
bcardarella-blackbook-1.0.8 lib/blackbook/exporter/xml.rb
bcardarella-blackbook-1.0.9 lib/blackbook/exporter/xml.rb
briancollins-blackbook-1.0.15 lib/blackbook/exporter/xml.rb
rakutenusa-blackbook-1.0.12 lib/blackbook/exporter/xml.rb
rakutenusa-blackbook-1.0.13 lib/blackbook/exporter/xml.rb
rakutenusa-blackbook-1.0.14 lib/blackbook/exporter/xml.rb
rakutenusa-blackbook-1.0.15 lib/blackbook/exporter/xml.rb
rakutenusa-blackbook-1.0.16 lib/blackbook/exporter/xml.rb
rakutenusa-blackbook-1.0.17 lib/blackbook/exporter/xml.rb
rakutenusa-blackbook-1.0.18 lib/blackbook/exporter/xml.rb
rakutenusa-blackbook-1.0.19 lib/blackbook/exporter/xml.rb
blackbook-1.0.3 lib/blackbook/exporter/xml.rb
blackbook-1.0.2 lib/blackbook/exporter/xml.rb
blackbook-1.0.1 lib/blackbook/exporter/xml.rb