XML File, or Array?

Hi, quick question:

I’m making (or attempting to) make a dialogue system using Xml to store the information. I’ve got my head around how to do it, but I was wondering, do I need to store the Xml info in an array, or can I just access the file each time it’s needed without any performance/loading issues.

The files themselves aren’t that big, and are brought into the script as a TextAsset.

Accessing a file is always much slower than accessing data in memory. Especially when you have to search for data.

If the files aren’t big and loading them won’t introduce memory problems (which might be important on mobiles), then I suggest preloading the data at the beginning of game. Or alternatively, if different files are loaded at different stages of your game, then you can load required files at the beginning of the stage.

I don’t know the structure of your files, but if you can simply load their raw data (without xml tags) into arrays - go for it. But if the structure is more complicated (nodes have attributes, child nodes, etc.), then you need to prepare a proper classes in your game and then use them to deserialize your files. If you don’t know what deserialization is, please read this Unity Wiki page and maybe this MSDN page.