Rudy_TM
Rudy_TM

Reputation: 1430

Reading and Writing XML VS Plain Text

Which method is more efficient in speed and memory?

Writing and reading a xml file (parsing too) or reading and writing a plain text file, i want to manipulate data(not long one, but structurated)

Upvotes: 0

Views: 2916

Answers (2)

John3136
John3136

Reputation: 29266

Plain text is probably more efficient for speed and memory - especially if you can "structure" it using like CSV or some other common separator. What you are giving up though is:

  • XML is very "human readable" (self documenting)
  • Parsers/data structure generators already exist, so XML could be faster to develop.

People worry too much about speed and memory efficiency (especially memory!) - do whatever is easiest then optimize it if it is too slow!

Without knowing you data: something very simple (no optional fields, 1 record type etc) I'd go with something like CSV. Having said that, the latest file I've made was XML using JAXB to generate structures, parse the file etc.

Upvotes: 1

Qurben
Qurben

Reputation: 1316

You can make plain text faster than xml, but xml is more structured and easier to read.

When you use just plain text you will have to somehow 'deserialize' your text to variables, it depends on the way you do this how efficient your method is.

Upvotes: 0

Related Questions