當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlDocument.AddRootNode方法代碼示例

本文整理匯總了C#中System.Xml.XmlDocument.AddRootNode方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlDocument.AddRootNode方法的具體用法?C# XmlDocument.AddRootNode怎麽用?C# XmlDocument.AddRootNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.XmlDocument的用法示例。


在下文中一共展示了XmlDocument.AddRootNode方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Should_add_root_node

 public void Should_add_root_node()
 {
     XmlDocument xmlDoc = new XmlDocument();
     XmlNode rootNode = xmlDoc.AddRootNode("root");
     Check.That(xmlDoc.ChildNodes[1]).IsEqualTo(rootNode);
     Check.That(xmlDoc.ChildNodes[1].Name).IsEqualTo(rootNode.Name);
 }
開發者ID:xcasadio,項目名稱:TinyParser,代碼行數:7,代碼來源:XmlExtensionTest.cs

示例2: SaveFile

        /// <summary>
        /// 
        /// </summary>
        /// <param name="fileName"></param>
        public static bool SaveFile(string fileName)
        {
            const int version = 1;

            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlNode rootNode = xmlDoc.AddRootNode("FlowSimulator");
                rootNode.AddAttribute("version", version.ToString());

                FlowGraphManager.Instance.Save(rootNode);
                NamedVariableManager.Instance.Save(rootNode);

                xmlDoc.Save(fileName);

                LogManager.Instance.WriteLine(LogVerbosity.Info, "'{0}' successfully saved", fileName);
            }
            catch (System.Exception ex)
            {
                LogManager.Instance.WriteException(ex);
                return false;
            }

            return true;
        }
開發者ID:xcasadio,項目名稱:FlowGraph,代碼行數:29,代碼來源:ProjectManager.cs

示例3: Should_add_attribute_to_node

 public void Should_add_attribute_to_node()
 {
     XmlDocument xmlDoc = new XmlDocument();
     XmlNode rootNode = xmlDoc.AddRootNode("root");
     rootNode.AddAttribute("attribute", "value");
     Check.That(rootNode.Attributes["attribute"].Value).IsEqualTo("value");
 }
開發者ID:xcasadio,項目名稱:TinyParser,代碼行數:7,代碼來源:XmlExtensionTest.cs

示例4: Should_add_node_text

 public void Should_add_node_text()
 {
     XmlDocument xmlDoc = new XmlDocument();
     xmlDoc.AddRootNode("root");
     XmlElement nodeTxt = xmlDoc.CreateElementWithText("Text", "value");
     Check.That(nodeTxt.Name).IsEqualTo("Text");
     Check.That(nodeTxt.InnerText).IsEqualTo("value");
 }
開發者ID:xcasadio,項目名稱:TinyParser,代碼行數:8,代碼來源:XmlExtensionTest.cs

示例5: SaveSettings

        /// <summary>
        /// 
        /// </summary>
        private void SaveSettings()
        {
            var serializer = new XmlLayoutSerializer(dockingManager1);
            using (var stream = new StreamWriter(m_DockSettingsFile))
            {
                serializer.Serialize(stream);
            }

            XmlDocument xmlDoc = new XmlDocument();
            XmlNode rootNode = xmlDoc.AddRootNode("FlowSimulator");
            rootNode.AddAttribute("version", "1");
            XmlNode winNode = xmlDoc.CreateElement("Window");
            rootNode.AppendChild(winNode);
            winNode.AddAttribute("version", "1");

            if (WindowState == WindowState.Minimized)
            {
                winNode.AddAttribute("windowState", Enum.GetName(typeof(WindowState), WindowState.Normal));
                winNode.AddAttribute("left", m_LastLeft.ToString());
                winNode.AddAttribute("top", m_LastTop.ToString());
                winNode.AddAttribute("width", m_LastWidth.ToString());
                winNode.AddAttribute("height", m_LastHeight.ToString());
            }
            else
            {
                winNode.AddAttribute("windowState", Enum.GetName(typeof(WindowState), WindowState));
                winNode.AddAttribute("left", Left.ToString());
                winNode.AddAttribute("top", Top.ToString());
                winNode.AddAttribute("width", Width.ToString());
                winNode.AddAttribute("height", Height.ToString());
            }

            //             m_SessionControl.SaveSettings(rootNode);
            //             m_MessageControl.SaveSettings(rootNode);
            //             m_TaskControl.SaveSettings(rootNode);
            //             m_ReportControl.SaveSettings(rootNode);
            //             m_LogControl.SaveSettings(rootNode);
            //             m_ScriptControl.SaveSettings(rootNode);

            xmlDoc.Save(m_UserSettingsFile);
        }
開發者ID:xcasadio,項目名稱:FlowGraph,代碼行數:44,代碼來源:MainWindow.xaml.cs


注:本文中的System.Xml.XmlDocument.AddRootNode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。