Schlagwort-Archive: XML

Do not use „indent“ while generating XML files

For XML reading and writing I use the component TJvSimpleXML from the JediVCL library. The component has an option sxoAutoIndent for saving the XML content to string/file. This will add blanks to the output XML to generate a file which can be (good) read by humans. Example:

<XML>
  <ITEMS>
    <ITEM1>value1</ITEM1>
    <ITEM2>value2</ITEM2>
    <ITEM3>value3</ITEM3>
  </ITEMS>
</XML>

But the generated file is much larger. I had an input XML without indent which is 42 MB. After processing and saving the size is 127 MB! Just because blanks were added. If You generate files only for machine processing do not use indents. The needed HDD/RAM space is lower and the processing time increase.

Example without indent:

<XML>
<ITEMS>
<ITEM1>value1</ITEM1>
<ITEM2>value2</ITEM2>
<ITEM3>value3</ITEM3>
</ITEMS>
</XML>