format_xml_elements($array)
drupal-5/includes/common.inc, line 912
Format XML elements.
In both cases, 'value' can be a simple string, or it can be another array with the same format as $array itself for nesting.
$array An array where each item represent an element and is either a:
| Name | Description |
|---|---|
| Formatting | Functions to format numbers, strings, dates, etc. |
| Input validation | Functions to validate user input. |
<?php
function format_xml_elements($array) {
foreach ($array as $key => $value) {
if (is_numeric($key)) {
if ($value['key']) {
$output .= ' <'. $value['key'];
if (isset($value['attributes']) && is_array($value['attributes'])) {
$output .= drupal_attributes($value['attributes']);
}
if ($value['value'] != '') {
$output .= '>'. (is_array($value['value']) ? format_xml_elements($value['value']) : check_plain($value['value'])) .'</'. $value['key'] .">\n";
}
else {
$output .= " />\n";
}
}
}
else {
$output .= ' <'. $key .'>'. (is_array($value) ? format_xml_elements($value) : check_plain($value)) ."</$key>\n";
}
}
return $output;
}
?>