Site Name

Xml is a Joke

Way back in the ancient times of 2006 I had a boss who wrote a xml sax parser in C++ because libraries were hard i guess. I got to debug bugs and use it and evntually wrote a object representation on top of it which used more memory and was 10% less awful to use. But everything was terrible so xml probably just didn’t have good libraries right.

Today I had to edit someone’s app.config and append to xml attributes that were really maps[string][]string / Dictionary<string,List> that were hand serialized as"foo:bar,bunk;moo:brown,cow"

Yuck. But this was just some awful dev right? So I aked to friends how they would serialize a map dict in xml.

I got

    <Key>my key</Key>
        <Entry>First one</Entry>
        <Entry> Second one </Entry>


  <entry key="key">value</entry>

Okay those are better but certainly not consisteny. What does my old buddy powershell do

> @{foo="paul"} | ConvertTo-Xml -as string
<?xml version="1.0" encoding="utf-8"?>
  <Object Type="System.Collections.Hashtable">
    <Property Name="Key" Type="System.String">foo</Property>
    <Property Name="Value" Type="System.String">paul</Property>

Woof that’s not great here’s json for comparsion

> @{foo="paul"} | ConvertTo-Json
  "foo": "paul"

What aboutu go and python? Turns out their standard library marshallers won’t even take maps/dicts.

Maps/dicts seem like pretty fundamental data types. Maybe XML was just never good all along.