Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My biggest hatred of xml as a data structure, and believe me I've seen this in production systems more then once, is that it allows for the following.

  <customer>
	<account>
		<type>Personal</type>
		...
	</account>
	<account>
		<type>Business</type>
		...
	</account>
	<custid>496F3AB</custid>
  </customer>
This may seem innocuous, but XML allows mixing of arrays and objects too liberally, and makes automatic parsing overly complex. At first <customer> appears to be an array of account objects, but wait now that we reach the end we find that <customer> is an object with multiple keys and must create an unnamed array key to hold accounts.

XML is a document markup language, not a data format.



Well yes. The problem there is that someone made a bad decision on how to structure their XML. If the same was done like this:

      <customer custid="496F3AB">
    	<account>
    		<type>Personal</type>
    		...
    	</account>
    	<account>
    		<type>Business</type>
    		...
    	</account>
      </customer>
it would make a lot more sense, I think.


Which problem XML makes all too easy.

The really annoying issue is as the parent says, that the accounts collection does not have a name. This means there's no canonical mapping for the structure into a programming language object, which necessitates that libraries require annotations or some other side-channel way of specifying how to wrap the accounts into a collection.

In Jaxb e.g., how many times must we add junk like:

  @XmlElementWrapper(name = "accounts")  ?
In any individual case the workaround is easy, but it's annoying to have to do it repeatedly.

XML really is better as document markup than structured data representation.


Or:

      <customer>
        <custid>496F3AB</custid>
        <accounts>
           <account>
    	     <type>Personal</type>
             ...
    	   </account>
    	   <account>
    	     <type>Business</type>
    	     ...
    	   </account>
    	</accounts>
      </customer>




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: