Summarizing, how can I write data to my .xnb XML file which I read from before?
I've the following:
Editable XML file in my project's content folder:
<?xml version="1.0" encoding="utf-8" ?>
<XnaContent>
<Asset Type="TestProgram_Data.Data">
<Number>123</Number>
</Asset>
</XnaContent>
My Data class:
namespace TestProgram_Data
{
public class Data
{
public int Number;
}
}
Now I can load data from a compiled XML file (.xnb, XNA content file) like this:
Data data = new Data();
Console.WriteLine("Number: " + data.Number); // Output: "Number: 123"
But how can I write to this file (.xnb file under Content folder)?
data.Number = 123456789; // Doesn't work
I tried to use XmlWriter with IntermediateSerializer, but it's made a normal XML file. I can make an .xnb file with this, too, but in this case the .xnb file isn't compiled (I can edit with Notepad, isn't part of my project, and if I run again my program, the default data [eg. 123] loads again - because I read from my .xnb file and not from the other file which created with XmlWriter).
At all, is possible to save data back to the .xnb file, from I read in the past?