zoukankan      html  css  js  c++  java
  • 生成XML文件

      //创建XML
            XmlDocument StandardXml = new XmlDocument();
            void sc_MouseDoubleClick(object sender, MouseEventArgs e)
            {
                Dot3D dot1 = this.scenControl.WpToLp(e.X, e.Y);
    
                //添加第一行编码等格式。
                XmlDeclaration _Describe = StandardXml.CreateXmlDeclaration("1.0", "gb2312", "yes");
                StandardXml.AppendChild(_Describe);
                //创建第一个大节点
                XmlElement xml = StandardXml.CreateElement("XML");
    
                XmlElement firstXML = StandardXml.CreateElement("firstXML");
    
                XmlElement Xzhou = StandardXml.CreateElement("Xzhou");
                Xzhou.InnerText = dot1.X.ToString();
                firstXML.AppendChild(Xzhou);
    
                XmlElement Yzhou = StandardXml.CreateElement("Yzhou");
                Yzhou.InnerText = dot1.Y.ToString(); 
                firstXML.AppendChild(Yzhou);
    
                XmlElement Zzhou = StandardXml.CreateElement("Zzhou");
                Zzhou.InnerText = dot1.Z.ToString();
                firstXML.AppendChild(Zzhou);
    
                xml.AppendChild(firstXML);
                StandardXml.AppendChild(xml);
    
                StandardXml.Save("E://paishuikou.xml");
                if (File.Exists("E://paishuikou.xml"))
                {
                    MessageBox.Show("保存成功!");
                }
    }
  • 相关阅读:
    设计模式(十):Decorator装饰者模式 -- 结构型模式
    设计模式(九):Composite组合模式 -- 结构型模式
    Anagrams
    Gas Station
    Unique Binary Search Trees II
    Trapping Rain Water
    4Sum
    3Sum Closest
    3Sum
    Longest Valid Parentheses
  • 原文地址:https://www.cnblogs.com/youmingkuang/p/5620770.html
Copyright © 2011-2022 走看看