To elaborate on what James told you, the general problem with XML is
that this format has no semantic encoded in the markup used:
* In any XML element, you might have simple values encoded
either with attributes on this element or with child elements,
and you can have an attribute and a child element with the same
names.
<foo bar="baz">
<bar>baz</bar>
</foo>
How do you map this to a map?
* XML elements on the save level (that is, children elements of any XML
element) might perfectly have the same names:
<foo>
<bar>1</bar>
<bar>2</bar>
...
<bar>42</bar>
</foo>
As you can see, it's impossible to automatically map the contents of
<foo>...</foo> to a map.
* Ordering of XML elements on the same level (see above) may or may not
matter.
Again, if you take the example above, the semantics of processing
XML documents of this type might dictate that all those <bar> elements
for an ordered list or they form an unordered set.
* If the bytes between the two tags of an element do not contain any
other XML elements, there's still no way to infer the "type" of this
value, that is, given <bar>42</bar>, you can't tell if 42 must be
a string or an integer or a float, so basically there's no sense
to unmarshal an XML document to map[string]interface{} because you
can only sensibly unmarshal to map[string]string. JSON at least
differentiates between objects, arrays, strings and numbers.
* An often forgotten fact (especially when dealing with XML produced
by in-house tools) is that XML uses namespaces for everything, that
is, each element and attribute of any XML document you're working with
has a namespace which may be specified either explicitly or via a
prefix or implied from the context.
It also worth citing the encoding/xml manual:
| Mapping between XML elements and data structures is inherently
| flawed: an XML element is an order-dependent collection of anonymous
| values, while a data structure is an order-independent collection of
| named values. See package json for a textual representation more
| suitable to data structures.