I’ve been reading about serialization, and I don’t really understand why we use XML files instead of txt files for example? I’ve been trying reading data from a txt file and it works perfectly fine. What are the reasons for using XML?
Thank you.
I’ve been reading about serialization, and I don’t really understand why we use XML
Share
An xml file is basically a text file, following the rules for xml formatting.
The main advantage of xml files is that they are hierarchical. Consider e.g. the following XML:
Here we have two different data types: people and cars. With the hierarchical structure of XML it is easy to represent the owner of each car.
It is of course possible to do something similar without using XML, but then you would have to do a lot of string manipulation yourself to parse the information. With XML there is at least one xml library available for every major programming language.