function patterns_xmlparser_array_to_xml in Patterns 7.2
Same name and namespace in other branches
- 7 patterns_xmlparser/patterns_xmlparser.module \patterns_xmlparser_array_to_xml()
1 call to patterns_xmlparser_array_to_xml()
- patterns_xmlparser_dump in patterns_xmlparser/
patterns_xmlparser.module
File
- patterns_xmlparser/
patterns_xmlparser.module, line 95
Code
function patterns_xmlparser_array_to_xml($array, &$xml) {
foreach ($array as $key => $value) {
if (is_array($value)) {
if (!is_numeric($key)) {
$subnode = $xml
->addChild("{$key}");
patterns_xmlparser_array_to_xml($value, $subnode);
}
else {
patterns_xmlparser_array_to_xml($value, $xml);
}
}
elseif (!empty($key) && $key == 'tag') {
$xml
->addAttribute("{$key}", "{$value}");
}
else {
if (is_numeric($key) || empty($key)) {
$key = 'value';
}
// HTML character may generate a warning. We don't care
@$xml
->addChild("{$key}", "{$value}");
}
}
}