XML parsing and normalization

First target is to map something like <root><key>value</key></root> to something like ["key": "value"] . I wrote an XMLTree to map Data to [String: Any] (mapping in XML is simpler than JSON 'cause Any can be just String or [String: Any] ). I’ve used the event-driven XMLParser to build a navigable tree of XMLNode .

In this step I faced mainly two issues, summarized in two examples:

<root>

<foo id="1">bar</foo>

</root>

I have chosen to treat the anonymous value as an attribute with the key _value.

["key": [ "id": "1", "_value": "bar"]]

I know this isn’t the cleanest solution, but it’s enough quick’n’dirty to pass the 1st release.

But go ahead with the second problem:

<root>

<foo>1</foo>

<foo>2</foo>

<foo>3</foo>

<foo>4</foo>

</root>