【发布时间】:2014-12-08 06:46:10
【问题描述】:
我有这个问题,每当我保存包含“\t”的 xml 属性值(例如:MyNetwork\trash)时,我都会收到“MyNetwork rash”。此外,还有一些文本中的 '\n' 被更改为十六进制值。
下面是我正在使用的代码。
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();
请帮帮我。
【问题讨论】:
-
路径 = @"MyNetwork\trash"
标签: c# xml xmldocument