Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is fast to read, .xml, .ini or .txt? [closed]

Tags:

c#

.net

io

xml

ini

My application has to read the data stored in a file and get the values for the variables or arrays to work on them.

My question is, that which file format will be fast and easy for retrieval of data from the file.

I was thinking to use .xml, .ini , or just a simple .txt file. But to read .txt file i will have to write a lot of code with many if or else conditions.

I dont know how to use .ini and .xml. But if they will better and fast so i'll learn them first, and then i'll use them. Kindly guide me.

like image 309
Shaharyar Avatar asked Dec 20 '22 10:12

Shaharyar


1 Answers

I will assume what you are indicating here is that raw performance is not a priority over robustness of the system.

For simple data which is a value paired with a name, an ini would probably be simplest solution. More complex structured data would lead you toward XML. According to a previously asked question if you are working in C# (and hence it's assumed in .Net) XML is generally preferred as it has been built into the .Net libraries. As xml is more flexible and can change with needs of the program, I would also personally recommend xml over ini as a file standard. It will take more work to learn the XML library, however it will quickly pay off and is a standardized system.

Text could be fast, but you would be sacrificing either a vast sum of robust parsing behavior for the sake of speed or spending far more man hours developing and maintaining a high speed specialized parser.

For references on reading in xml files: (natively supported in .Net libraries)

  • MSDN XMLTextReader Article
  • MSDN XMLReader Article
  • Writing Data to XML with XMLSerializer

For references on reading in ini files: (not natively supported in .Net libraries)

  • Related Question
like image 145
Ian T. Small Avatar answered Dec 23 '22 00:12

Ian T. Small