3 ms·
It can be done like this too: <fruit> <id>10</id> <name>orange</name> </fruit> Which one is better? I find it hard to decide, and I believe most people d
by slig 13y ago
It can be done like this too:
<fruit>
<id>10</id>
<name>orange</name>
</fruit>
Which one is better? I find it hard to decide, and I believe most people do. And that's why we see it mixed, often in the same XML document.
- bananas 13y agoThe one you use is better (correct).
- spopejoy 13y agoUtterly disagree. Attributes can actually have validated contents, such as enumerated lists, etc, and are attractively terse. Over-reliance on elements are why Maven pom files are such a verbose disaster, and probably the main reason why web developers puke when trying to stream data. Restating element names make for illegible, bloated data. Attribute-heavy XML is attractively terse and benefits from validation (unlike JSON).
- bananas 13y agoBut you can't change an attribute to a composite type in the future easily. As for maven POMs, I use Netbeans "add dependency" and that's about it so it's a non issue for me.