I created a simple preset management system to save and load my presets as xml files. But I want to change the one of the attribute’s value. I tried to do something like this:
- create a memory block
- create a file array and fill it with preset files.
- load the current file’s content to memory block as data.
- (This is the part that I need help) Parse the data, find a parameter that you want to change, then change it
- replace the content of the file with new memory block data.
- go to beginning and repeat every for all presets
I also tried to create a memoryInputStream to get the memory block data as binary data then I tried to turn it into a string to use string methods to find the part that I want to change. Finally after changing the string , I tried to go through all these steps back and replace the file’s content with new data by using a memoryOutputStream. But it throws errors and it does not work correctly . That is why I didn’t put it here. Could you please help me to find a proper way to do this?
Should I try to create an xml file and copy the content of the file to it, and then try to use xml methods ? Is it possible to show me a few lines about it?
or Should I try to change that parameter value just after the scanning the presets and try to save the file without dealing with parsing? (I don’t want to do this actually because I want to learn how to deal with files.)
or Am I completely on the wrong way ?