System:Xml:arrayToXml

From Aspen Documentation

Turns an array into a basic xml response. This function requires DOMDocument to be installed and available.

Since 1.0

Contents

Arguments

string arrayToXml ([array $inc_array = false])

inc_array
An array of values to be written as xml.

Returns

Returns a string of xml content, or false if no valid array is passed.

Notes

  • As noted in bug 1095 This function does not currently support multi-dimensional arrays.

Examples

By passing the below array:

$test = array('first'=>'John','last'=>'Doe','age'=>37);
print $this->APP->xml->arrayToXml($test);

We'll get the following XML string:

<?xml version="1.0"?>
<response>
  <first>John</first>
  <last>Doe</last>
  <age>37</age>
</response>