the xml-rpc specification defines six basic data types and two compound data types that represent combinations of types.
basic data types in xml-rpc
type | value | examples |
---|---|---|
int or i4 | 32-bit integers between - 2,147,483,648 and 2,147,483,647. |
<int>27</int> <i4>27</i4> |
double | 64-bit floating-point numbers |
<double>27.31415</double> <double>-1.1465</double> |
boolean | true (1) or false (0) |
<boolean>1</boolean> <boolean>0</boolean> |
string | ascii text, though many implementations support unicode |
<string>hello</string> <string>bonkers! @</string> |
datetime.iso8601 | dates in iso8601 format: ccyymmddthh:mm:ss |
<datetime.iso8601> 20021125t02:20:04 </datetime.iso8601> <datetime.iso8601> 20020104t17:27:30 </datetime.iso8601> |
base64 | binary information encoded as base 64, as defined in rfc 2045 |
<base64>sgvsbg8sifdvcmxkiq==</base64> |
these basic types are always enclosed in value elements. strings (and only strings) may be enclosed in a value element but omit the string element. these basic types may be combined into two more complex types, arrays, and structs. arrays represent sequential information, while structs represent name-value pairs, much like hashtables, associative arrays, or properties.
arrays are indicated by the array element, which contains a data element holding the list of values. like other data types, the array element must be enclosed in a value element. for example, the following arraycontains four strings:
<value> <array> <data> <value><string>this </string></value> <value><string>is </string></value> <value><string>an </string></value> <value><string>array.</string></value> </data> </array> </value>
the following array contains four integers:
<value> <array> <data> <value><int>7</int></value> <value><int>1247</int></value> <value><int>-91</int></value> <value><int>42</int></value> </data> </array> </value>
arrays can also contain mixtures of different types, as shown here:
<value> <array> <data> <value><boolean>1</boolean></value> <value><string>chaotic collection, eh?</string></value> <value><int>-91</int></value> <value><double>42.14159265</double></value> </data> </array> </value>
creating multidimensional arrays is simple - just add an array inside of an array:
<value> <array> <data> <value> <array> <data> <value><int>10</int></value> <value><int>20</int></value> <value><int>30</int></value> </data> </array> </value> <value> <array> <data> <value><int>15</int></value> <value><int>25</int></value> <value><int>35</int></value> </data> </array> </value> </data> </array> </value>
a simple struct might look like:
<value> <struct> <member> <name>givenname</name> <value><string>joseph</string></value> </member> <member> <name>familyname</name> <value><string>dinardo</string></value> </member> <member> <name>age</name> <value><int>27</int></value> </member> </struct> </value>
this way you can implement almost all data types supported by any programming language.