Added support for null values: empty xml tag

This commit is contained in:
Luís Jesus
2025-03-26 11:09:20 +00:00
parent 52666b2780
commit 63884cd5ea

View File

@@ -57,7 +57,12 @@ const convertObjectToXml = (
: `${escapeXml(String(item))}`;
xml += `</${keyString}>${newline}`;
});
} else if (typeof value === 'object' && value !== null) {
} else if (value === null) {
xml += `${getIndentation(
options,
depth
)}<${keyString}></${keyString}>${newline}`;
} else if (typeof value === 'object') {
xml += `${getIndentation(options, depth)}<${keyString}>${newline}`;
xml += convertObjectToXml(value, options, depth + 1);
xml += `${getIndentation(options, depth)}</${keyString}>${newline}`;