API: If key begins with '@' treat it as an xml attribute

This commit is contained in:
Tom Needham 2013-01-24 10:39:33 +00:00
parent 8f9d3cd01d
commit 02f8c941f4

View file

@ -188,18 +188,25 @@ class OC_API {
}
private static function toXML($array, $writer) {
foreach($array as $k => $v) {
if (is_numeric($k)) {
if (substr($k, 0, 1) === '@') {
$writer->writeAttribute(substr($k, 1), $v);
continue;
} else if (is_numeric($k)) {
$k = 'element';
}
if (is_array($v)) {
if(is_array($v)) {
$writer->startElement($k);
self::toXML($v, $writer);
$writer->endElement();
} else {
$writer->writeElement($k, $v);
}
}
}
}