Quote:Original post by m-sambo
I'm using xml as a file format for a map editor. My first thought was to use mainly attributes for things like position, item name, etc but after reading a few tutorials I decided to use elements only. No particular reason besides others had recomended this.
m-sambo
The main reason I would rec. attributes for maps is becasue of size. Here is an example from a Map Maker I made a while back using XML and MFC.
This is the optimized attribute form. The file size was 45kb. It represented the graphic index layers. As you can see everything is as compact as possible to get the smallest possible map.
<?xml version="1.0" encoding="utf-8" ?><Map><D0_0><h L0="0" L1="0" L2="0" L3="0" /></D0_0><D0_1><h L0="0" L1="0" L2="0" L3="0" /></D0_1><D0_2><h L0="0" L1="0" L2="0" L3="0" /></D0_2><D0_3><h L0="0" L1="0" L2="0" L3="0" /></D0_3><D0_4><h L0="0" L1="0" L2="0" L3="0" /></D0_4>...
Now if I would had used the other method, I would be adding so much additional data that would bloat the map. Normally I had a nicer format to this map, It was like:
<?xml version="1.0" encoding="utf-8" ?><Map><Row_0_Col_0><Layers Layer_0="0" Layer_1="0" Layer_2="0" Layer_3="0" /></Row_0_Col_0>...
But as you can see the extra code. Now if I were to use the <> </> method for all of those elements were looking at at least a 50% increase in data size. The first method had 46 characters in the first line and the second method had about 86. With the element style, add at least another 40 characters. Now for small maps this is acceptable - but try making a 100x100 tiled map!
I am not saying you should use either or - its just from experience, I know that you want the most amount of data represented in the least possible size - of which the attributes method is superior to. If you need to see real proof of the size difference, I think I still have my map generator that switches between expanded names and short optimized names. I'm sure I can dig it out or just write another one. Good luck!
- Drew