XML/HTML: Do we need the element name in closing tags

htmljsonreadabilitytaggingxml

Compared to other serialization languages, one of the main criticisms directed at XML is its verbosity; JSON's more terse and readable for most cases, but not all.

But it seems to me that we could cut a lot of the excess from XML simply by stripping away the names from the closing tags. With proper indentation readability shouldn't be an issue (it should be an improvement, if you ask me), and since they're not structurally required any decent XML editor/viewer could easily be made to strip/hide or add them. As such, the two formats should be completely equivalent and interchangeable.

Compare the following (source taken from http://www.w3schools.com/xml/simple.xml):

<breakfast_menu>
    <food>
        <name>Belgian Waffles</name>
        <price>$5.95</price>
        <description>
                    Two of our famous Belgian Waffles with plenty of real maple syrup
        </description>
        <calories>650</calories>
    </food>
    <food>
        <name>Strawberry Belgian Waffles</name>
        <price>$7.95</price>
        <description>
                    Light Belgian waffles covered with strawberries and whipped cream
        </description>
        <calories>900</calories>
    </food>
    <food>
        <name>Berry-Berry Belgian Waffles</name>
        <price>$8.95</price>
        <description>
                    Light Belgian waffles covered with an assortment of fresh berries and whipped cream
        </description>
        <calories>900</calories>
    </food>
    <food>
        <name>French Toast</name>
        <price>$4.50</price>
        <description>
                    Thick slices made from our homemade sourdough bread
        </description>
        <calories>600</calories>
    </food>
    <food>
        <name>Homestyle Breakfast</name>
        <price>$6.95</price>
        <description>
                    Two eggs, bacon or sausage, toast, and our ever-popular hash browns
        </description>
        <calories>950</calories>
    </food>
</breakfast_menu>

and

<breakfast_menu>
    <food>
        <name>Belgian Waffles</>
        <price>$5.95</>
        <description>
                        Two of our famous Belgian Waffles with plenty of real maple syrup
        </>
        <calories>650</>
    </>
    <food>
        <name>Strawberry Belgian Waffles</>
        <price>$7.95</>
        <description>
                        Light Belgian waffles covered with strawberries and whipped cream
        </>
        <calories>900</>
    </>
    <food>
        <name>Berry-Berry Belgian Waffles</>
        <price>$8.95</>
        <description>
                        Light Belgian waffles covered with an assortment of fresh berries and whipped cream
        </>
        <calories>900</>
    </>
    <food>
        <name>French Toast</>
        <price>$4.50</>
        <description>
                        Thick slices made from our homemade sourdough bread
        </>
        <calories>600</>
    </>
    <food>
        <name>Homestyle Breakfast</>
        <price>$6.95</>
        <description>
                        Two eggs, bacon or sausage, toast, and our ever-popular hash browns
        </>
        <calories>950</>
    </>
</>

Best Answer

Can we change XML format (i.e. create a new language which doesn't have the verbosity issue)? Yes, we can.

In order to completely migrate to the "better XML" (let's call it BETXML), it would require to:

  • Reimplement all the parsers,

  • Rewrite all applications which currently use XML,

  • Rewrite all protocols based on XML.

Or we can keep everything in place, and just invent a new language and wait until it starts to be adapted everywhere. The only issue is that benefits of a new language are very limited. Applications which require less verbose language already use JSON. How would you convince people that BETXML is superior to XML and JSON?