Skip to content
Tags

XML-RPC Types: Dates vs. Strings

10 Dec 2009

The XML-RPC spec outlines 6 types: integer, boolean, string, double, date/time and base64. If you count struct and array as types then we go up to 8 types. The XML-RPC page on Wikipedia has examples of the XML tags for these data types.

One mistake that I’ve seen commonly made (and I’ve done it myself) is to confuse dates and strings. It’s easy to do, most databases for instance treat date input essentially as a string. So it might seem natural that a date would be encoded in XML-RPC as:

<string>19980717T14:08:55</string>

and expect the XML-RPC server to just know that it should be converting that value to a date/time. XML-RPC libraries massage the encoded values based on the XML tag though, so this gets treated as a string. The correct mark up for a date/time value would be:

<datetime.iso8601>19980717T14:08:55</datetime.iso8601>

An XML-RPC library will then put this into a correct date context for that specific programming language.

If you find that a date field in your XML-RPC request isn’t being processed correctly take a look at the raw XML, you may actually be passing it as a string. When a problem comes up spending a minute to verify the XML tag can save you a bigger headache later on.

Related posts:

  1. jQuery Edit In Place (JEIP)
  2. Joe Gregorio on AtomPub and XML
  3. WordPress 2.8 – XML-RPC and AtomPub Changes
  4. WordPress 2.8.1 – XML-RPC and AtomPub Changes
  5. Conclusion of libxml2 Issues – Use PHP 5.2.9 & libxml2 2.7.3

From → Posts

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS