What is the best way to store XML data used in a program ? Use RESX file or store it as a .xml file and load and unload the files as per requirement
.resx files are XML files albeit conforming to a particular schema (Microsoft ResX Schema v2.0). This schema was designed with the explicit aim of being easily human readable and editable manually.
I see no problem with storing your data as XML files. Basically it depends on the function of the data - If it is localizable resources that you are trying to store, go with the established .resx files. If not, you are free to use your XML with custom schema.
A third option would be to put the XML file as embedded resource in the assembly. In that case, use Assembly.GetManifestResourceStream() to load the XML.
As Cerebrus wrote, when localization is necessary, RESX would be the way to go.
Putting XML (blobs) in .resx
Positives:
- Readily available
Negatives:
- It would increase the memory load, if the content is big in size. Big-in-size is in comparison to assembly size without content. If an assembly size is 10kb and content size is 10kb, even though 10kb is not bigger in today's scenario, one can reduce assembly size to half just by keeping content in separate file.
- Code manageability goes to down drastically, by keeping XML as string Key-value-pairs in RESX. As resx editor is not be XML sensitive.
If one is very keen keeping xml content as embedded resource, you can create XML file and keep it as file resource inside RESX.