4 ms·
For somebody who want to make XML shorter and more human-readable: 1. Use more attributes, i.e.: <employee first="Steve" last="Jobs/> instead of <employ
by nivertech 16y ago
For somebody who want to make XML shorter and more human-readable:
1. Use more attributes, i.e.:
<employee first="Steve" last="Jobs/>
instead of
<employee>
<first>Steve</first>
<last>Jobs</last>
</employee>
2. Use Camel case instead of '_', i.e.:
<MyElementName>XXX</MyElementName>
instead of:
<my_element_name>XXX</my_element_name>
3. Use sane namespace prefixes.
4. Write XSD schema (or generate it from example XML document) - Tools like XMLSpy really helpfull in filling complex XMLs.
- Groxx 16y ago1 is a good example of something I see people doing wrong with XML on a regular basis. If there can't be a list of items, it should be an attribute, not a node.
- nivertech 16y agoActually it's abuse of attributes, since attributes must be metadata only, while data itself should be in element content. But it makes large XML files much more readable ...
- Groxx 16y agoOnly because you don't tend to find XML tidiers that display like this: <node_name attr="value" attr2="value2"> always this: <node_name attr="value" attr2="value2" etc="etc" ad="infinitum" until="you have to scroll"> edit: On a <person>, how do you define what's data and what's metadata? Is a name data or metadata? What's the difference between data and metadata in the first place, in a concrete, testable definition? Google define:metadata says: data about data; "a library catalog is metadata because it describes publications" So a library catalog should be like this? <library name="of congress" 978_3_16_148410_0="<data title=\"\">contents</data>" 978_3_16_148410_1="<data title=\"\">contents</data>" etc > (intentionally reducto-ad-absurdum)
- cperciva 16y agoSome of us find unix_style names far more readable than CamelCase. Underscores are almost spaces and make it much easier to recognize where each word starts.
- nailer 16y agoWouldn't unix style be uxixstyle?