this post was submitted on 24 Jan 2026
56 points (93.8% liked)

Programming

24651 readers
114 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
 

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."

you are viewing a single comment's thread
view the rest of the comments
[–] Kissaki@programming.dev 4 points 1 day ago (1 children)

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 10 points 1 day ago* (last edited 1 day ago) (1 children)

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>
[–] Kissaki@programming.dev 4 points 22 hours ago* (last edited 22 hours ago) (1 children)

https://www.w3.org/TR/2004/REC-xml-infoset-20040204/

[children] An ordered list of child information items, in document order.

Does this not cover it?

Do you mean if you were to follow XML standard but not XML information set standard?

[–] Feyd@programming.dev 3 points 22 hours ago (1 children)

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.

[–] Kissaki@programming.dev 1 points 12 hours ago* (last edited 12 hours ago) (1 children)

If the XML parser parses into an ordered representation (the XML information set), isn't it then the deserializer's choice how they map that to the programming language/type system they are deserializing to? So in a system with ordered arrays it would likely map to those?

If XML can be written in an ordered way, and the parsed XML information set has ordered children for those, I still don't see where order gets lost or is impossible [to guarantee] in XML.

[–] Feyd@programming.dev 1 points 12 hours ago

You are correct that it is the deserializer's choice. You are incorrect when you imply that it is a good idea to rely on behavior that isn't enforced in the spec. A lot of people have been surprised when that assumption turns out to be wrong.