There exists a peculiar amnesia in software engineering regarding XML. Mention it in most circles and you will receive knowing smiles, dismissive waves, the sort of patronizing acknowledgment reserved for technologies deemed passé. “Oh, XML,” they say, as if the very syllables carry the weight of obsolescence. “We use JSON now. Much cleaner.”

  • Feyd@programming.dev
    link
    fedilink
    arrow-up
    8
    ·
    19 hours ago

    JSON also has arrays. In XML the practice to approximate arrays is to put the index as an attribute. It’s incredibly gross.

    • Kissaki@programming.devOP
      link
      fedilink
      English
      arrow-up
      4
      arrow-down
      1
      ·
      17 hours ago

      In XML the practice to approximate arrays is to put the index as an attribute. It’s incredibly gross.

      I don’t think I’ve seen that much if ever.

      Typically, XML repeats tag names. Repeating keys are not possible in JSON, but are possible in XML.

      <items>
        <item></item>
        <item></item>
        <item></item>
      </items>
      
      • Feyd@programming.dev
        link
        fedilink
        arrow-up
        8
        ·
        edit-2
        17 hours ago

        That’s correct, but the order of tags in XML is not meaningful, and if you parse then write that, it can change order according to the spec. Hence, what you put would be something like the following if it was intended to represent an array.

        <items>
          <item index="1"></item>
          <item index="2"></item>
          <item index="3"></item>
        </items>
        
          • Feyd@programming.dev
            link
            fedilink
            arrow-up
            2
            ·
            5 hours ago

            Information set isn’t a description of XML documents, but a description of what you have that you can write to XML, or what you’d get when you parse XML.

            This is the key part from the document you linked

            The information set of an XML document is defined to be the one obtained by parsing it according to the rules of the specification whose version corresponds to that of the document.

            This is also a great example of the complexity of the XML specifications. Most people do not fully understand them, which is a negative aspect for a tool.

            As an aside, you can have an enforced order in XML, but you have to also use XSD so you can specify xsd:sequence, which adds complexity and precludes ordered arrays in arbitrary documents.