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


C# XmlDocument.GetEnumerator方法代码示例

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


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

示例1: GetConfigInfo

 /// <summary>
 /// get configuration
 /// </summary>
 private void GetConfigInfo()
 {
     try
     {
         var document = new XmlDocument();
         document.Load(AppDomain.CurrentDomain.BaseDirectory + FilePath);
         var elements = document.GetEnumerator();
         while (elements.MoveNext())
         {
             var xmlNode = elements.Current as XmlNode;
             if (xmlNode.HasChildNodes)
             {
                 SetDictionary(xmlNode);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
开发者ID:luoyanfu,项目名称:AutoCoder,代码行数:24,代码来源:Config.cs

示例2: ProtocolPrint


//.........这里部分代码省略.........
                         docTemplate.ReplaceText(string.Concat(new object[]
                         {
                             "<",
                             stalaName,
                             "*",
                             x,
                             ">"
                         }), stalaValue.Substring(j, 1), false, System.Text.RegularExpressions.RegexOptions.None, null, null, MatchFormattingOptions.SubsetMatch);
                         x++;
                     }
                     if (fCount < iCount)
                     {
                         for (int k = fCount; k <= iCount; k++)
                         {
                             docTemplate.ReplaceText(string.Concat(new object[]
                             {
                                 "<",
                                 stalaName,
                                 "*",
                                 k,
                                 ">"
                             }), "*", false, System.Text.RegularExpressions.RegexOptions.None, null, null, MatchFormattingOptions.SubsetMatch);
                         }
                     }
                 }
                 if (iCount == 1)
                 {
                     docTemplate.ReplaceText("<" + stalaName + ">", stalaValue, false, System.Text.RegularExpressions.RegexOptions.None, null, null, MatchFormattingOptions.SubsetMatch);
                 }
             }
             System.Collections.IEnumerator enumerator;
             if (xmlValues.Attributes.Count > 0)
             {
                 enumerator = xmlValues.Attributes.GetEnumerator();
                 try
                 {
                     while (enumerator.MoveNext())
                     {
                         XmlAttribute xAttr = (XmlAttribute)enumerator.Current;
                         System.Collections.Generic.List<int> i = docTemplate.FindAll("<" + xAttr.Name);
                         int iCount = i.Count;
                         int fCount = xAttr.InnerText.Length;
                         int x = 2;
                         if (iCount > 1)
                         {
                             docTemplate.ReplaceText("<" + xAttr.Name + ">", xAttr.InnerText.Substring(fCount - 1, 1), false, System.Text.RegularExpressions.RegexOptions.None, null, null, MatchFormattingOptions.SubsetMatch);
                             for (int j = fCount - 2; j >= 0; j--)
                             {
                                 docTemplate.ReplaceText(string.Concat(new object[]
                                 {
                                     "<",
                                     xAttr.Name,
                                     "*",
                                     x,
                                     ">"
                                 }), xAttr.InnerText.Substring(j, 1), false, System.Text.RegularExpressions.RegexOptions.None, null, null, MatchFormattingOptions.SubsetMatch);
                                 x++;
                             }
                             if (fCount < iCount)
                             {
                                 for (int k = fCount; k <= iCount; k++)
                                 {
                                     docTemplate.ReplaceText(string.Concat(new object[]
                                     {
                                         "<",
                                         xAttr.Name,
开发者ID:nicholaspaun,项目名称:Kalkulator1,代码行数:67,代码来源:printProtocolNew.cs

示例3: Rebuild

 public void Rebuild()
 {
     Program.AssertOnEventThread();
     if (_xenObject is DockerContainer)
     {
         RefreshTime.Text = String.Format(Messages.LAST_REFRESH_SUCCESS, DateTime.Now.ToString("HH:mm:ss"));
         try
         {
             string expectResult = "True";
             var args = new Dictionary<string, string>{};
             args["vmuuid"] = _vmResideOn.uuid;
             args["object"] = _container.uuid;
             Session session = _container.Connection.DuplicateSession();
             string CurrentResult = XenAPI.Host.call_plugin(session, _hostResideOn.opaque_ref, "xscontainer", "get_inspect", args);
             if (_resultCache == CurrentResult)
                 return;
             else
                 _resultCache = CurrentResult;
             DetailtreeView.Nodes.Clear();
             if (CurrentResult.StartsWith(expectResult))
             {
                 CurrentResult = CurrentResult.Substring(expectResult.Length);
                 XmlDocument doc = new XmlDocument();
                 doc.LoadXml(CurrentResult);
                 IEnumerator ienum = doc.GetEnumerator();
                 XmlNode docker_inspect;
                 while (ienum.MoveNext())
                 {
                     docker_inspect = (XmlNode)ienum.Current;
                     if (docker_inspect.NodeType != XmlNodeType.XmlDeclaration)
                     {
                         TreeNode rootNode = new TreeNode();
                         CreateTree(docker_inspect, rootNode);
                         DetailtreeView.Nodes.Add(rootNode);
                     }
                 }
             }
             else
             {
                 RefreshTime.Text = Messages.LAST_REFRESH_FAIL;
             }
         }
         catch (Failure failure)
         {
             RefreshTime.Text = Messages.LAST_REFRESH_FAIL;
             log.WarnFormat("Plugin call xscontainer.get_inspect({0}) on {1} failed with {2}", _container.uuid, _hostResideOn.Name,
                 failure.Message);
             throw;
         }
     }
 }
开发者ID:robertbreker,项目名称:xenadmin,代码行数:51,代码来源:DockerDetailsPage.cs

示例4: Rebuild

        public void Rebuild(string currentResult)
        {
            Program.AssertOnEventThread();
            RefreshTime.Text = string.Format(Messages.LAST_REFRESH_SUCCESS,
                                             HelpersGUI.DateTimeToString(DateTime.Now, Messages.DATEFORMAT_HMS, true));
            try
            {
                if (cachedResult == currentResult)
                    return;

                cachedResult = currentResult;
                DetailtreeView.Nodes.Clear();

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(currentResult);
                
                IEnumerator firstEnum = doc.GetEnumerator();
                XmlNode node;
                while (firstEnum.MoveNext())
                {
                    node = (XmlNode)firstEnum.Current;

                    if (node.NodeType != XmlNodeType.XmlDeclaration)
                    {
                        //we are on the root element now (docker_inspect)
                        //using the following enumerator to iterate through the children nodes and to build related sub-trees
                        //note that we are intentionally not adding the root node to the tree (UX decision)
                        var secondEnum = node.GetEnumerator();
                        while (secondEnum.MoveNext())
                        {
                            //recursively building the tree
                            TreeNode rootNode = new TreeNode();
                            CreateTree((XmlNode)secondEnum.Current, rootNode);

                            //adding the current sub-tree to the TreeView
                            DetailtreeView.Nodes.Add(rootNode);
                        }
                    }
                }
            }
            catch (Failure)
            {
                ShowInvalidInfo();
            }
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:45,代码来源:DockerDetailsPage.cs


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