当前位置: 首页>>代码示例>>C#>>正文


C# System.Xml.XmlDocument.InsertBefore方法代码示例

本文整理汇总了C#中System.Xml.XmlDocument.InsertBefore方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlDocument.InsertBefore方法的具体用法?C# System.Xml.XmlDocument.InsertBefore怎么用?C# System.Xml.XmlDocument.InsertBefore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlDocument的用法示例。


在下文中一共展示了System.Xml.XmlDocument.InsertBefore方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveTo

        public static void SaveTo(string path)
        {
            path = System.IO.Path.GetFullPath(path);

            FullPath = path;

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            var element = Data.IO.SaveObjectToElement(doc, "Root", Core.Root, false);

            var behaviorElement = Data.IO.SaveObjectToElement(doc, "Behavior", EffectBehavior, false);
            var cullingElement = Data.IO.SaveObjectToElement(doc, "Culling", Culling, false);

            System.Xml.XmlElement project_root = doc.CreateElement("EffekseerProject");

            project_root.AppendChild(element);

            if(behaviorElement != null) project_root.AppendChild(behaviorElement);
            if (cullingElement != null) project_root.AppendChild(cullingElement);

            project_root.AppendChild(doc.CreateTextElement("ToolVersion", Core.Version));
            project_root.AppendChild(doc.CreateTextElement("Version", 3));
            project_root.AppendChild(doc.CreateTextElement("StartFrame", StartFrame));
            project_root.AppendChild(doc.CreateTextElement("EndFrame", EndFrame));
            project_root.AppendChild(doc.CreateTextElement("IsLoop", IsLoop.ToString()));

            doc.AppendChild(project_root);

            var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
            doc.InsertBefore(dec, project_root);
            doc.Save(path);
            IsChanged = false;

            if (OnAfterSave != null)
            {
                OnAfterSave(null, null);
            }
        }
开发者ID:kou-yeung,项目名称:Effekseer,代码行数:38,代码来源:Core.cs

示例2: SaveConfig

        internal static void SaveConfig()
        {
            {
                var rf = GetRecentFiles();

                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                System.Xml.XmlElement project_root = doc.CreateElement("Recent");

                foreach (var f in rf.Reverse())
                {
                    project_root.AppendChild(doc.CreateTextElement("File", f));
                }

                doc.AppendChild(project_root);

                var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
                doc.InsertBefore(dec, project_root);
                doc.Save(configRecentPath);
            }

            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                System.Xml.XmlElement project_root = doc.CreateElement("GUI");

                if (MainForm.WindowState == FormWindowState.Normal)
                {
                    project_root.AppendChild(doc.CreateTextElement("X", MainForm.Location.X.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Y", MainForm.Location.Y.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Width", MainForm.Width.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Height", MainForm.Height.ToString()));
                }
                else // 最小化、最大化中はその前の位置とサイズを保存
                {
                    project_root.AppendChild(doc.CreateTextElement("X", MainForm.BeforeResizeLocation.X.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Y", MainForm.BeforeResizeLocation.Y.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Width", MainForm.BeforeResizeWidth.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Height", MainForm.BeforeResizeHeight.ToString()));
                }
                doc.AppendChild(project_root);

                var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
                doc.InsertBefore(dec, project_root);
                doc.Save(configGuiPath);
            }

            MainForm.Panel.SaveAsXml(configGuiPanelPath, Encoding.UTF8);

            Network.Save(configNetworkPath);
        }
开发者ID:saihe,项目名称:Effekseer,代码行数:51,代码来源:GUIManager.cs

示例3: SaveOption

        public static void SaveOption()
        {
            var path = System.IO.Path.Combine(GetEntryDirectory(), OptionFilePath);

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            var optionElement = Data.IO.SaveObjectToElement(doc, "Option", Option, false);

            System.Xml.XmlElement project_root = doc.CreateElement("EffekseerProject");
            if(optionElement != null) project_root.AppendChild(optionElement);

            doc.AppendChild(project_root);

            var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
            doc.InsertBefore(dec, project_root);
            doc.Save(path);
            IsChanged = false;
        }
开发者ID:kou-yeung,项目名称:Effekseer,代码行数:18,代码来源:Core.cs

示例4: CheckAndFixXMLInput

        void CheckAndFixXMLInput(string Filename)
        {
            System.Xml.XmlDocument xmld = new System.Xml.XmlDocument();
            xmld.Load(Filename);
            if (xmld.FirstChild.NodeType != System.Xml.XmlNodeType.XmlDeclaration)
            {
                System.Xml.XmlAttribute atr;
                System.Xml.XmlNode node;
                DateTime dt;

                atr = xmld.CreateAttribute("xmlns:xsd");
                atr.Value = "http://www.w3.org/2001/XMLSchema";
                xmld.FirstChild.Attributes.Append(atr);
                atr = xmld.CreateAttribute("xmlns:xsi");
                atr.Value = "http://www.w3.org/2001/XMLSchema-instance" ;
                xmld.FirstChild.Attributes.Append(atr);
                atr = xmld.CreateAttribute("xmlns");
                atr.Value = "http://carverlab.com/xsd/VideoExchange.xsd";
                xmld.FirstChild.Attributes.Append(atr);
                xmld.InsertBefore(xmld.CreateXmlDeclaration("1.0","utf-8",""),xmld.FirstChild);
                node = xmld.SelectSingleNode("CARDVIDEO/TIMESTART");
                dt = DateTime.Parse(node.InnerText);
                node.InnerText = dt.ToString("s",System.Globalization.DateTimeFormatInfo.InvariantInfo);
                node = xmld.SelectSingleNode("CARDVIDEO/TIMESTOP");
                dt = DateTime.Parse(node.InnerText);
                node.InnerText = dt.ToString("s",System.Globalization.DateTimeFormatInfo.InvariantInfo);
                xmld.Save(Filename);
            }
        }
开发者ID:CarverLab,项目名称:Oyster,代码行数:29,代码来源:EncodeLauncher.cs

示例5: SaveXmlDefaultConfigurationFile

        /// <summary>
        /// Create and Save a default configuration Xml file based on a easily specific or default defined xml string
        /// </summary>
        /// <param name="FilePath">The fullpath including filename.xml to save to</param>
        /// <param name="XmlConfigurationFileString">If not specified, then will use the XmlDefaultConfigurationFileString</param>
        /// <returns>True if succesfull created</returns>
        /// <remarks></remarks>
        public bool SaveXmlDefaultConfigurationFile(string FilePath, string XmlConfigurationFileString)
        {
            string theXmlString = ((XmlConfigurationFileString != null) ? XmlConfigurationFileString : XmlDefaultConfigurationFileString);
            //What Method You want to use ?, try any by simply change the var XmlSaveMethod declared at top
            switch (XmlSaveMethod) {
                case enumXmlSaveMethod.StreamWrite:
                    //Easy Method
                    using (System.IO.StreamWriter StreamWriter = new System.IO.StreamWriter(FilePath)) {
                        //Without Compact Framework more easily using file.WriteAllText but, CF doesn't have this method
                        StreamWriter.Write(theXmlString);
                        StreamWriter.Close();
                    }

                    return true;

                case enumXmlSaveMethod.XmlTextWriter:
                    //Alternative Method
                    using (System.Xml.XmlTextWriter XmlTextWriter = new System.Xml.XmlTextWriter(FilePath, System.Text.UTF8Encoding.UTF8)) {
                        XmlTextWriter.WriteStartDocument();
                        XmlTextWriter.WriteStartElement("configuration");
                        XmlTextWriter.WriteStartElement("appSettings");
                        foreach (string Item in GetListItems(theXmlString)) {
                            XmlTextWriter.WriteStartElement("add");

                            XmlTextWriter.WriteStartAttribute("key", string.Empty);
                            XmlTextWriter.WriteRaw(GetKey(Item));
                            XmlTextWriter.WriteEndAttribute();

                            XmlTextWriter.WriteStartAttribute("value", string.Empty);
                            XmlTextWriter.WriteRaw(GetValue(Item));
                            XmlTextWriter.WriteEndAttribute();

                            XmlTextWriter.WriteEndElement();

                        }

                        XmlTextWriter.WriteEndElement();
                        XmlTextWriter.WriteEndElement();
                        //XmlTextWriter.WriteEndDocument()
                        XmlTextWriter.Close();

                    }

                    return true;

                case enumXmlSaveMethod.XmlDocument:
                    //Method you will practice
                    System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument();
                    System.Xml.XmlElement xRoot = XmlDoc.CreateElement("configuration");
                    XmlDoc.AppendChild(xRoot);
                    System.Xml.XmlElement xAppSettingsElement = XmlDoc.CreateElement("appSettings");
                    xRoot.AppendChild(xAppSettingsElement);

                    System.Xml.XmlElement xElement = default(System.Xml.XmlElement);
                    System.Xml.XmlAttribute xAttrKey = default(System.Xml.XmlAttribute);
                    System.Xml.XmlAttribute xAttrValue = default(System.Xml.XmlAttribute);
                    foreach (string Item in GetListItems(theXmlString)) {
                        xElement = XmlDoc.CreateElement("add");
                        xAttrKey = XmlDoc.CreateAttribute("key");
                        xAttrValue = XmlDoc.CreateAttribute("value");
                        xAttrKey.InnerText = GetKey(Item);
                        xElement.SetAttributeNode(xAttrKey);
                        xAttrValue.InnerText = GetValue(Item);
                        xElement.SetAttributeNode(xAttrValue);
                        xAppSettingsElement.AppendChild(xElement);
                    }

                    System.Xml.XmlProcessingInstruction XmlPI = XmlDoc.CreateProcessingInstruction("xml", "version='1.0' encoding='utf-8'");
                    XmlDoc.InsertBefore(XmlPI, XmlDoc.ChildNodes[0]);
                    XmlDoc.Save(FilePath);

                    return true;
            }
            return false;
        }
开发者ID:hjgode,项目名称:eMdiMail,代码行数:82,代码来源:AppSettings.cs

示例6: SaveXmlCurrentConfiguration

        public object SaveXmlCurrentConfiguration(string StrPath, string StrFilename /*= "AppSettings.xml"*/)
        {
            //Conform the Path
            string FilePath = (!(StrPath == null) ? StrPath : System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)) + "\\" + StrFilename;

            System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument();
            System.Xml.XmlElement xRoot = XmlDoc.CreateElement("configuration");
            XmlDoc.AppendChild(xRoot);
            System.Xml.XmlElement xAppSettingsElement = XmlDoc.CreateElement("appSettings");
            xRoot.AppendChild(xAppSettingsElement);

            System.Xml.XmlElement xElement = default(System.Xml.XmlElement);
            System.Xml.XmlAttribute xAttrKey = default(System.Xml.XmlAttribute);
            System.Xml.XmlAttribute xAttrValue = default(System.Xml.XmlAttribute);
            //For Each Item As String In Me.ListItems
            for (int i = 0; i <= this.ListItems.Count - 1; i++) {
                xElement = XmlDoc.CreateElement("add");
                xAttrKey = XmlDoc.CreateAttribute("key");
                xAttrValue = XmlDoc.CreateAttribute("value");
                xAttrKey.InnerText = this.ListItems.GetKey(i);
                xElement.SetAttributeNode(xAttrKey);
                xAttrValue.InnerText = this.ListItems[i];
                xElement.SetAttributeNode(xAttrValue);
                xAppSettingsElement.AppendChild(xElement);
            }
            System.Xml.XmlProcessingInstruction XmlPI = XmlDoc.CreateProcessingInstruction("xml", "version='1.0' encoding='utf-8'");
            XmlDoc.InsertBefore(XmlPI, XmlDoc.ChildNodes[0]);
            XmlDoc.Save(FilePath);
            return true;
        }
开发者ID:hjgode,项目名称:eMdiMail,代码行数:30,代码来源:AppSettings.cs

示例7: Read

 public void Read(string Filename)
 {
     // now load this bugger up and get rid or all the junk that WMP can't parse
     System.Xml.XmlDocument xmld = new System.Xml.XmlDocument();
     xmld.Load(Filename);
     System.Xml.XmlDeclaration xmldecl = xmld.CreateXmlDeclaration("1.0",null,null);
     xmld.InsertBefore(xmldecl,xmld.DocumentElement);
     string TempFile = System.IO.Path.GetTempFileName();
     xmld.Save(TempFile);
     System.IO.TextReader tw = System.IO.File.OpenText(TempFile);
     m_asx = (CarverLab.Utility.ASX)base.Deserialize(tw);
     tw.Close();
     System.IO.File.Delete(TempFile);
 }
开发者ID:CarverLab,项目名称:Oyster,代码行数:14,代码来源:asx.cs


注:本文中的System.Xml.XmlDocument.InsertBefore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。