aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/xml/writer.js9
-rw-r--r--tests/xml/writer.tests.js5
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/xml/writer.js b/lib/xml/writer.js
index e48f3a1..a97d17e 100644
--- a/lib/xml/writer.js
+++ b/lib/xml/writer.js
@@ -5,11 +5,14 @@ exports.writeString = writeString;
function writeString(root) {
- return xmlbuilder
+ var builder = xmlbuilder
.create(root.name, {
version: '1.0',
encoding: 'UTF-8',
standalone: true
- })
- .end();
+ });
+ root.children.forEach(function(child) {
+ builder.element(child.name);
+ });
+ return builder.end();
}
diff --git a/tests/xml/writer.tests.js b/tests/xml/writer.tests.js
index f2408e0..5ffecc2 100644
--- a/tests/xml/writer.tests.js
+++ b/tests/xml/writer.tests.js
@@ -9,6 +9,11 @@ describe('xml.writer', function() {
test('writing empty root element writes out xml declaration and empty root element', function() {
assertXmlString(new Element("root"), '<root/>');
});
+
+ test('can write empty child elements', function() {
+ assertXmlString(new Element("root", {}, [new Element("album"), new Element("single")]),
+ '<root><album/><single/></root>');
+ });
});