zoukankan      html  css  js  c++  java
  • 用XmlTextWriter写出的XML文件没有换行,用记事本打开XML文件的时候都写在了一行上,请问怎样加入换行!

    来源:http://social.microsoft.com/Forums/es-ES/visualcshartzhchs/thread/f0b1f040-724c-48d3-aa59-b828e45ddeca

    这个是我的程序代码?请问怎样让写出的XML文件里都一行一行的!

    using (XmlTextWriter xwriter = new XmlTextWriter(songlocation , null))
                {
                    xwriter.WriteStartDocument();
                    xwriter.WriteStartElement("myplayer");
                    xwriter.WriteStartElement("playingsongs");
                    xwriter.WriteAttributeString("total",songlist.Count .ToString ());
                    for (int i = 0; i < songlist.Count ;i++ )
                    {
                        xwriter.WriteAttributeString("song"+i.ToString (),songlist[i ].ToString ());
                    }
                    xwriter.WriteEndElement();
                    xwriter.WriteEndElement();
                    xwriter.WriteEndDocument();
                    xwriter.Flush();
                    xwriter.Close();
                }

    // 写入XML文档            

                XmlTextWriter writer = null;
                try
                {

                    writer = new XmlTextWriter(filePath, System.Text.Encoding.UTF8);
                    writer.Formatting = Formatting.Indented;
                    writer.WriteStartDocument();
                    writer.WriteStartElement("Log");
                }
                finally
                {
                    if (writer != null)
                        writer.Close();
                }

     

  • 相关阅读:
    UIView的clipsToBounds属性,layoutSubViews及触摸事件传递(默认情况下)总结
    ISO中运行时简单使用及KVC补充
    IOS中UISearchBar的使用
    oc的block
    oc的协议(protocol)
    oc的分类category
    oc内存的理解
    oc笔记(转载)
    oc对象中属性总结
    servlet,struts1,struts2,spring
  • 原文地址:https://www.cnblogs.com/dabaopku/p/1726746.html
Copyright © 2011-2022 走看看