I have been writing some code to update attributes' value in a XML file.
I use the XDocument's load method to load the file ; I wanted update some values in the file, but the final application (a mix software called Virtual DJ) that read the XML doesn't read it at all (unfortunately, there is no error message).
One thing leading to another, I wanted just load the file and save it without updating anything (I thought that the operation might have screwed up all the nodes)
XDocument db = XDocument.Load(DbFilePath);
If I specify that no formatting must be applied, the result is still the same:
The problem is still the same : the newly generated file can't be read by the application. I insist on it: nothing is different between those 2 files, visualy speaking
There is something more strange : if I copy a node from the generated file to the original XML file (the file that can be read by the final application), the new node can't be read and the piece of information that is related to that node isn't correclty displayed in the application.
Trust me, the pasted node is EXACTLY the same (visualy speaking I mean)
If I only copy and paste some attribute's value, there is no problem. Once I copy an expression starting with "<" and leading with ">", it sucks.
I use a different method to generate the file : I supposedly think taht CR and LF may be wrongly written.
I use a StreamWriter object :
private static void WriteInFile(string path, string stream)
using (StreamWriter swriter = File.AppendText(path))
As a conclusion, neither XDocument.Save() nor a StreamWriter has solved the issue.
Frankly, I don't know what's wrong.
I tested each char from the newly XML generated file, there is no "bad" character:
if ((char == 0x9) ||
(char == 0xA) ||
(char == 0xD) ||
((char >= 0x20) && (char <= 0xD7FF)) ||
((char >= 0xE000) && (char <= 0xFFFD))
Also, I check out the file's permission of the the newly genrated xml : permissions are the same that the riginal one.
Do you have any explanation? What do you recommand to do?
Thanks for reading the message.