Data Exchange with XML, WDDX and PHP - Polly Wants A Cracker (
Page 3 of 9 )
Since WDDX data follows the basic rules of XML markup, it can easily be validated against a DTD. And if you look at the DTD, you'll quickly see that all WDDX "packets" are constructed in a standard format.
The root, or document, element for WDDX data is always the <wddxPacket> element, which marks the beginning and end of a WDDX block.
<wddxPacket version='1.0'>
This is immediately followed by a header containing comments,
<header>
<comment>Who da man?</comment>
</header>
and a data area containing the XML representation of the data structure.
<data>
...
</data>
</wddxPacket>
This data area can contain any of WDDX's basic datatypes, which are described in detail in the WDDX DTD - here's the short version, with examples:
Boolean values, represented by the element <boolean> - for example
<wddxPacket version='1.0'>
<header/>
<data>
<struct>
<var name='validUser'>
<boolean value='true'/>
</var>
</struct>
</data>
</wddxPacket>
Numbers, represented by the element <number> - for example
<wddxPacket version='1.0'>
<header/>
<data>
<struct>
<var name='page'>
<number>76</number>
</var>
</struct>
</data>
</wddxPacket>
String values, represented by the element <string> - for example
<wddxPacket version='1.0'>
<header/>
<data>
<struct>
<var name='phrase'>
<string>Polly wants a cracker</string>
</var>
</struct>
</data>
</wddxPacket>
Arrays and hashes (or associative arrays), represented by the elements <array> and <struct> respectively - for example
<wddxPacket version='1.0'>
<header/>
<data>
<struct>
<var name='desserts'>
<array length='5'>
<string>apple pie</string>
<string>angel food cake</string>
<string>chocolate fudge</string>
<string>strawberries and cream</string>
<string>tiramisu</string>
</array>
</var>
</struct>
</data>
</wddxPacket>
Tabular data, represented by the element <recordset> - for example
<wddxPacket version='1.0'>
<header/>
<data>
<recordset rowCount="2" fieldNames="symbol, price">
<field name="symbol">
<string>HDST</string>
<string>BDGF</string>
</field>
<field name="price">
<number>56.78</number>
<number>373.03</number>
</field>
</recordset>
</data>
</wddxPacket>
Timestamps, represented by the element <dateTime> - for example
<wddxPacket version='1.0'>
<header/>
<data>
<struct>
<var name='today'>
<dateTime>2001-08-08T16:48:23</dateTime>
</var>
</struct>
</data>
</wddxPacket>