首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

请问一个c#写XML换行的有关问题

2012-09-13 
请教一个c#写XML换行的问题有一个XML文件,其中有一段是这样的XML codeDeviceFacilitySMIC-F8Technolog

请教一个c#写XML换行的问题
有一个XML文件,其中有一段是这样的

XML code
  <Device    Facility="SMIC-F8"    Technology="1118C014.N7NOW"    WaferSize="300"    EdgeExclusion="3000"    NotchExclusionWidth="12500"    NotchExclusionHeight="3500"    WaferConfigFile="SMIC-F8_1118C014.N7NOW_F781537B_20111104000000_wfcfg.xml"    CreateDate="20111104000000"    Orientation="270"    ReticleOrientation="0"    />


用IE打开看各个属性是不换行的,但是用UE等编辑器打开是换行的
请问这个该如何实现?
谢谢!
PS. 开发环境:VS2010

[解决办法]
用XmlWriter来控制换行的问题:
C# code
            XDocument doc = new XDocument(                new XDeclaration("1.0", "utf-8", "yes"),                new XElement("Root",                    new XAttribute("attr1", "value"),                    new XAttribute("attr2", "value")                    )                );            Console.WriteLine(doc);            using (StreamWriter sw = new StreamWriter(@"D:\test.xml")) {                XmlWriterSettings settings = new XmlWriterSettings();                settings.Indent = true;                settings.IndentChars = "  ";                settings.NewLineOnAttributes = true;                XmlWriter xmlWriter = XmlWriter.Create(sw, settings);                doc.Save(xmlWriter);                xmlWriter.Close();            } 

热点排行