From c28c2da3b35dda56836a9fca5b5616d0a5f18294 Mon Sep 17 00:00:00 2001 From: mk-pmb Date: Mon, 2 Jan 2017 13:18:25 +0100 Subject: [PATCH] [fix] convert xml to string before calling .trim fixes #20 --- index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 6713b48..c3216d2 100644 --- a/index.js +++ b/index.js @@ -20,7 +20,7 @@ module.exports = parse; */ function parse(xml) { - xml = xml.trim(); + xml = String(xml).trim(); // strip comments xml = xml.replace(//g, ''); @@ -32,10 +32,14 @@ function parse(xml) { */ function document() { - return { - declaration: declaration(), - root: tag() + var doc = { declaration: declaration() }, moreDecl; + while (true) { + moreDecl = declaration(); + if (!moreDecl) { break; } + doc.declaration += moreDecl; } + doc.root = tag(); + return doc; } /**