i have this piece of code which i use to add some elements:
string xmlTarget = string.Format(@"<target name='{0}' type='{1}' layout='${{2}}' />",
new object[] { target.Name, target.Type, target.Layout });
Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var xmlDoc = XElement.Load(configuration.FilePath);
var nlog = xmlDoc.Elements("nlog");
if (nlog.Count() == 0)
{
return false;
}
xmlDoc.Elements("nlog").First().Elements("targets").First().Add(xmlTarget);
xmlDoc.Save(configuration.FilePath,SaveOptions.DisableFormatting);
configuration.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("nlog");
return true;
it supposed to add a target to the xml , problem is it replace "<" with "<
" and ">" with ">
" which mess up my xml file.
how do i fix this ?
Note please dont pay attention to nlog, i`m concerned about the linqtoxml problem.