From b4be29174d96de1b6176c200942b75278eab8142 Mon Sep 17 00:00:00 2001 From: Muhammet Ilendemli Date: Tue, 8 May 2018 08:26:05 +0200 Subject: [PATCH] fix array of same keyed items --- Sources/XMLParsing/XMLStackParser.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sources/XMLParsing/XMLStackParser.swift b/Sources/XMLParsing/XMLStackParser.swift index 6aea4f6..912d595 100644 --- a/Sources/XMLParsing/XMLStackParser.swift +++ b/Sources/XMLParsing/XMLStackParser.swift @@ -163,7 +163,15 @@ internal class _XMLElement { for childElement in children { for child in childElement.value { if let content = child.value { - node[childElement.key] = content + if let oldContent = node[childElement.key] as? Array { + node[childElement.key] = oldContent + [content] + + } else if let oldContent = node[childElement.key] { + node[childElement.key] = [oldContent, content] + + } else { + node[childElement.key] = content + } } else if !child.children.isEmpty || !child.attributes.isEmpty { let newValue = child.flatten()