0
+From http://www.openwddx.org/faq/:
0
+ WDDX is an XML-based technology that enables the exchange of complex data between Web programming languages,
0
+ creating what some refer to as 'Web syndicate networks'.
0
+ WDDX consists of a language-independent representation of data based on an XML 1.0 DTD, and a set of
0
+ modules for a wide variety of languages that use WDDX.
0
+ WDDX can be used with HTTP, SMTP, POP, FTP and other Internet protocols that support transferring textual data.
0
+WDDX Home: http://www.openwddx.org/
0
+The Ruby WDDX Gem enables easy usage of WDDX in Ruby.
0
+Copyright (C) 2005, 2006, 2007 by Stefan Saasen <s-NOSPAM-REMOVE@juretta.com> - http://juretta.com/
0
+Just run <tt>[sudo] gem install wddx</tt> to install the WDDX Gem.
0
+You can very easily deserialize WDDX data from a file or from a string.
0
+ # data.xml contains <?xml version="1.0">\
0
+ # <wddxPacket version='1.0'><header><comment>A comment</comment></header><data><string>Klaus Tester</string></data></wddxPacket>
0
+ wddx = WDDX.load(File.open("data.xml"))
0
+ puts wddx.comment # "A comment"
0
+ puts wddx.data.class # String
0
+ puts wddx.data # "Klaus Tester"
0
+WDDX.load accepts a string with xml content, a file object or any object that provides a +read+ method.
0
+ packet = WDDX.load(open("http://wddx.rubyforge.org/wddx.xml"))
0
+ packet = WDDX.load(File.open("data.xml"))
0
+ packet = WDDX.load(open("data.xml"))
0
+ xml = "<wddxPacket version='1.0'><header/><data><number>123.667</number></data></wddxPacket>"
0
+ packet = WDDX.load(xml)
0
+ puts w.data # => 123.667
0
+ <wddxPacket version='1.0'>
0
+ <string>a string</string>
0
+ p w.data # => {"aString"=>"a string", "aNull"=>nil}
0
+If the root element is a +struct+ you can use a shortcut version:
0
+ w.data["aString"] # => "a string"
0
+ w.aString # => "a string"
0
+The core Ruby Classes +Symbol+, +String+, +Numeric+, +true+, +false+, +nil+, +Hash+, +Array+ and +Time+ can be serialized by calling
0
+ "Stefan Saasen".to_wddx # => "<wddxPacket version='1.0'><header/><data>\
0
+ # <string>Stefan Saasen</string></data></wddxPacket>"
0
+ 123.667.to_wddx # => "<wddxPacket version='1.0'><header/><data>\
0
+ # <number>123.667</number></data></wddxPacket>"
0
+ Math::PI.to_wddx # => "<wddxPacket version='1.0'><header/><data>\
0
+ # <number>3.14159265358979</number></data></wddxPacket>"
0
+ [1000, "Klaus Tester"].to_wddx # => "<wddxPacket version='1.0'><header/><data>\
0
+ # <array length='2'><number>1000</number>\
0
+ # <string>Klaus Tester</string></array></data></wddxPacket>"
0
+You can use WDDX.dump to serialize Ruby objects.
0
+ WDDX.dump("Hallo Welt") # => "<wddxPacket version='1.0'><header/><data><string>Hallo Welt</string></data></wddxPacket>"
0
+Custom Ruby classes can be serialized by adding a +to_wddx_properties+ method (in the style of the YAML library) and calling WDDX.dump.
0
+ class SerializeFromOutside
0
+ def to_wddx_properties
0
+ obj = SerializeFromOutside.new("This is a", "This is b", 123)
0
+ WDDX.dump(obj) # => "<wddxPacket version='1.0'><header/><data><struct><var name='a'>\
0
+ # <string>This is a</string></var><var name='c'><number>123</number>\
0
+ # </var></struct></data></wddxPacket>"
0
+It is possible to include the WDDX module to get a behaviour similiar to the core Ruby classes.
0
+ attr_accessor :name, :value, :price
0
+ def to_wddx_properties
0
+ ["@name", :custom_price]
0
+ obj = MyObject.new("Stefan Saasen", 120)
0
+ # => "<wddxPacket version='1.0'><header/><data><struct><var name='name'>\
0
+ # <string>Stefan Saasen</string></var><var name='custom_price'><number>126.0</number>\
0
+ # </var></struct></data></wddxPacket>"
0
+WDDX defines some data types which can not be mapped to native ruby classes. WDDX::Binary represents a binary object (which is in fact a BASE64 encoded String). WDDX::RecordSet represents a RecordSet with data rows an column meta information.
0
+The following table shows the data type mapping WDDX <=> Ruby.
0
+ --------- ---------------------
0
+ Boolean TrueClass, FalseClass
0
+ Recordset WDDX::RecordSet
0
+You can add the wddx gem to your rails application to be able to serialize ActiveRecord objects to WDDX.
0
+In config/environment.rb add:
0
+ a_ar_obj.to_wddx # => <wddxPacket...
0
+Homepage:: http://rubyforge.org/projects/wddx/
0
+Blog:: http://juretta.com/
0
+Bugtracker:: http://rubyforge.org/tracker/?group_id=2715
0
+WDDX:: http://www.openwddx.org/
0
\ No newline at end of file