|
|
@@ -566,26 +566,27 @@ EOF';
|
|
|
$child = $dom->createElement($node);
|
|
|
if (!$parent) $parent = $dom;
|
|
|
if (is_array($data)) {
|
|
|
- foreach ($data as $key => $value) {
|
|
|
- if ((string)$key === '@attributes') {
|
|
|
- foreach ($value as $attrName => $attrValue) {
|
|
|
- $attr = $dom->createAttribute($attrName);
|
|
|
- $attr->value = $attrValue;
|
|
|
- $child->appendChild($attr);
|
|
|
+ if ($data) {
|
|
|
+ foreach ($data as $key => $value) {
|
|
|
+ if ((string)$key === '@attributes') {
|
|
|
+ foreach ($value as $attrName => $attrValue) {
|
|
|
+ $attr = $dom->createAttribute($attrName);
|
|
|
+ $attr->value = $attrValue;
|
|
|
+ $child->appendChild($attr);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (is_numeric($key)) $arrayToXML_rec($value, $dom, $node, $parent);
|
|
|
+ else $arrayToXML_rec($value, $dom, $key, $child);
|
|
|
}
|
|
|
- } else {
|
|
|
- if (is_numeric($key)) $arrayToXML_rec($value, $dom, $node, $parent);
|
|
|
- else $arrayToXML_rec($value, $dom, $key, $child);
|
|
|
}
|
|
|
- }
|
|
|
+ } else $parent->appendChild($child);
|
|
|
} else {
|
|
|
if ($data) {
|
|
|
if ($data == htmlspecialchars($data)) $child->nodeValue = $data;
|
|
|
else $child->appendChild($dom->createCDATASection($data));
|
|
|
} else $parent->appendChild($child);
|
|
|
}
|
|
|
- //if ($child->hasChildNodes())
|
|
|
- $parent->appendChild($child);
|
|
|
+ if ($child->hasChildNodes()) $parent->appendChild($child);
|
|
|
};
|
|
|
|
|
|
if (!is_array($array)) throw new Exception("First argument need to be an array");
|