Before XML became a standard and given all its shortcomings, what made XML so popular?

后端 未结 23 606
轻奢々
轻奢々 2021-02-04 09:01

Yes XML is human readable but so is comma delimited text and properties files.

XML is bloated, hard to parse, hard to modify in code, plus a ton of other problems that I

相关标签:
23条回答
  • 2021-02-04 09:54

    Do you remember the days before XML became popular? Data just wasn't easily interchangeable -- one program would take .csv files, the next .xls, the next EBSIDIC-formatted files. XML has its weaknesses, but it's structured, which makes it parsable and transformable.

    As you point out, CSV files are pretty portable. However, there's no meaning to them. What does column(14) mean to me? As opposed to <customer id="14"/>?

    0 讨论(0)
  • 2021-02-04 09:54

    The primary advantage it bestows is a system independent representation of hierarchical data. Comma delimited text and properties files are more appropriate in many places where XML was used, but the ability to represent complex data structures and data types, character set awareness, and standards document allowed it to be used as a good inter application exchange format.

    My minor improvement suggestion for the language is to change the way end tags work. Just imagine how much bandwidth and disk space would be saved if you could end a tag with </>, like <my_tag>blah</> instead of <my_tag>blah</my_tag>. You aren't allowed to have overlapping tags, so I don't know why the standard insists on even more text than it needed. In fact, why use angle brackets at all?

    The ugliness of the angle brackets is a good show of what it could have been: JSON. JavaScript Object Notation achieves most of the goals of XML with a lot less typing. Another alternate syntax that makes XML bearable is the Builder syntax, as used by Groovy and Ruby. It's much more natural and readable.

    0 讨论(0)
  • 2021-02-04 09:55

    It has many advantages, and few shortcomings. The main problem is the increased size of file and slower processing. However, there are advantages:

    • it is structured, so you write a parser only once
    • it supports data with nested structure (hierarchies, trees, etc.)
    • you can embed multiple types of data structure in a single XML
    • you can describe the schema (data types, etc.) with standard language (XSL...)
    0 讨论(0)
  • 2021-02-04 09:55

    another benefit of XML vs binary data is error resilliancy..

    for binary data, if a single bit goes wrong, the data are most likely unusable, with xml, as a last resort, you can still open it up and make corrections...

    0 讨论(0)
  • 2021-02-04 09:56

    How about the fact that it supports a standardized query language, XPath? That's pretty useful for me.

    0 讨论(0)
提交回复
热议问题