XmlDocument.Save changes text containing '\t' to tab



I have this issue wherein whenever I save the xml attribute value which contains '\t' (example: MyNetwork\trash), I get "MyNetwork rash". Also, there are some wherein the '\n' in the text get changed to a hexadecimal value.


Below is the code that I am using.



Config mmsConfig = new Config
{
Path = "MyNetwork\trash"
};

XmlDocument xml = new XmlDocument();
xml.Load(configFile);
XmlNodeList xmlNodeList = xml.SelectNodes("MMS");

foreach (XmlNode node in
from XmlNode xmlNode in xmlNodes
from XmlNode node in xmlNode.ChildNodes
select node)
{
if (node.Attributes == null)
{
throw new ArgumentNullException(configFile, "Unable to locate attributes");
}

if (node.Attributes["path"] != null)
{
node.Attributes["path"].Value = @config.Path;
}
}

XmlTextWriter xmlText = new XmlTextWriter(configFile, Encoding.UTF8);
xmlText.Formatting = Formatting.None;

xml.Save(xmlText);
xmlText.Close();


Please help me in this.


No comments:

Post a Comment