Jeff Lowery wrote:
What can be achieved by binary XML that can't
be similarly achieved using well-known text
compression algorithms?
Let me give a really trivial example that shows some of the
benefits.
Let's say that you had the following XML: (warning,
instructive but highly contrived example follows...)
<dataset>
<x>27</x>
<y>12</y>
</dataset>
There are about 45 bytes there if you count CRLF and the
pretty-printing spaces. Now, a binary encoding that was schema driven
would look at this and might replace the tags with index numbers which
would be stored as bytes. Thus, dataset becomes "1", x becomes "2" and
y becomes "3." The encoder, if it new that the values of x and y were
supposed to be integers might also replace the two character strings
with one byte integers. If the encoding was of the "tag-length-value"
family, it would first write a tag number to the stream, then a length
and then the value. This would give you the following sequence of 6
bytes for the XML above:
1 Dataset Tag
4 length of data included in Dataset
2 "x" tag
27 value of x
3 "y" tag
12 value of y
So, you could encode dataset in 3 bytes:
1 Dataset Tag
27 value of x
12 value of y