Logo         Community
  Trog
Services
The Company
Community
Columns
Your Account
Contact Us
 
 
Data Exchange With XML, WDDX And PHP
Find out why WDDX is the future for Web-based data exchange

| Polly Wants A Cracker |

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>



How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!


previous page more like this  print this article  next page
 
Search...
 
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
more...
 
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
more...
 
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
more...
 
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
more...
 
In cut!...
American Chai
The Core
Possession
more...
 
Find out how you can use this article on your own Web site!


Copyright © 1998-2018 Melonfire. All rights reserved
Terms and Conditions | Feedback