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


C# XmlReader.ReadSubtree方法代码示例

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


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

示例1: ReadXml

 public void ReadXml(XmlReader reader)
 {
     var elementName = string.Empty;
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element)
         {
             elementName = reader.Name;
             switch (elementName)
             {
                 case "TypeAliases":
                     {
                         var subReader = reader.ReadSubtree();
                         var aliases = new List<NetTypeAlias>();
                         while (subReader.ReadToFollowing("TypeAlias"))
                         {
                             var aliasReader = subReader.ReadSubtree();
                             var typeAlias = new NetTypeAlias();
                             typeAlias.ReadXml(aliasReader);
                             aliases.Add(typeAlias);
                         }
                         TypeAliases = aliases.ToArray();
                         break;
                     }
                 case "Snippets":
                     {
                         var subReader = reader.ReadSubtree();
                         var snippets = new List<Snippet>();
                         while (subReader.ReadToFollowing("Snippet"))
                         {
                             var snippet = new Snippet();
                             snippet.ReadXml(subReader);
                             snippets.Add(snippet);
                         }
                         Snippets = snippets.ToArray();
                         break;
                     }
             }
         }
         else if (reader.NodeType == XmlNodeType.Text)
         {
             switch (elementName)
             {
                 case "Modifiers":
                     Modifiers = reader.Value.Split(' ');
                     break;
                 case "MemberIdentifiers":
                     MemberIdentifiers = reader.Value.Split(' ');
                     break;
                 case "Keywords":
                     Keywords = reader.Value.Split(' ');
                     break;
             }
         }
         else if (reader.NodeType == XmlNodeType.EndElement)
         {
             elementName = string.Empty; 
         }
     }
 }
开发者ID:die-Deutsche-Orthopaedie,项目名称:LiteDevelop,代码行数:60,代码来源:NetLanguageData.cs

示例2: Deserialize

        public static ServiceResponse Deserialize(XmlReader reader, ServiceResponse serviceResponse)
        {
            if (reader.IsStartElement(DTD.Response.TagServiceResponse))
            {
                if (serviceResponse == null)
                {
                    serviceResponse = new ServiceResponse();
                }

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    do
                    {
                        #region <ERROR>
                        if (reader.IsStartElement(DTD.Response.ServiceResponse.TagError))
                        {
                            if(int.Parse(reader.GetAttribute(DTD.Error.TagNumber))!=0)
                            {
                                throw XMLErrorSerializer.Deserialize(reader.ReadSubtree());
                            }
                            else
                            {
                                reader.Skip();
                            }
                        }
                        #endregion <ERROR>

                        #region <OID>
                        if (reader.IsStartElement(DTD.TagOID))
                        {
                            serviceResponse.Oid = XMLAdaptorOIDSerializer.Deserialize(reader.ReadSubtree());
                        }
                        #endregion <OID>

                        #region <Arguments>
                        if (reader.IsStartElement(DTD.Response.ServiceResponse.TagArguments))
                        {
                            serviceResponse.Arguments = XMLArgumentsSerializer.Deserialize(reader.ReadSubtree());
                        }
                        #endregion <Arguments>
                    } while (reader.Read());
                }
                else
                {
                    reader.Skip();
                }
            }
            else
            {
                throw new ArgumentException("Xml Reader don't have the Service.Response in Start Element.", "XmlReader reader");
            }
            return serviceResponse;
        }
开发者ID:sgon1853,项目名称:UPM_MDD_Thesis,代码行数:54,代码来源:Service.Response.Serializer.cs

示例3: Read_dmdSec

        /// <summary> Reads the dmdSec at the current position in the XmlTextReader and associates it with the 
        /// entire package  </summary>
        /// <param name="Input_XmlReader"> Open XmlReader from which to read the metadata </param>
        /// <param name="Return_Package"> Package into which to read the metadata</param>
        /// <param name="Options"> Dictionary of any options which this METS section reader may utilize</param>
        /// <returns> TRUE if successful, otherwise FALSE</returns>
        public bool Read_dmdSec(XmlReader Input_XmlReader, SobekCM_Item Return_Package, Dictionary<string, object> Options)
        {
            // Ensure this metadata module extension exists
            LearningObjectMetadata lomInfo = Return_Package.Get_Metadata_Module(GlobalVar.IEEE_LOM_METADATA_MODULE_KEY) as LearningObjectMetadata;
            if (lomInfo == null)
            {
                lomInfo = new LearningObjectMetadata();
                Return_Package.Add_Metadata_Module(GlobalVar.IEEE_LOM_METADATA_MODULE_KEY, lomInfo);
            }

            // Loop through reading each XML node
            do
            {
                // If this is the end of this section, return
                if ((Input_XmlReader.NodeType == XmlNodeType.EndElement) && ((Input_XmlReader.Name == "METS:mdWrap") || (Input_XmlReader.Name == "mdWrap")))
                    return true;

                // get the right division information based on node type
                if (Input_XmlReader.NodeType == XmlNodeType.Element)
                {
                    string name = Input_XmlReader.Name.ToLower();
                    if (( lom_namespace.Length > 0 ) && ( name.IndexOf( lom_namespace ) == 0))
                        name = name.Substring(lom_namespace.Length);

                    switch (name)
                    {
                        case "general":
                            read_general(Input_XmlReader.ReadSubtree(), lomInfo);
                            break;

                        case "lifecycle":
                            read_lifecycle(Input_XmlReader.ReadSubtree(), lomInfo);
                            break;

                        case "technical":
                            read_technical(Input_XmlReader.ReadSubtree(), lomInfo);
                            break;

                        case "educational":
                            read_educational(Input_XmlReader.ReadSubtree(), lomInfo);
                            break;

                        case "classification":
                            read_classification(Input_XmlReader.ReadSubtree(), lomInfo);
                            break;

                    }
                }

            } while (Input_XmlReader.Read());

            return true;
        }
开发者ID:randomyed,项目名称:SobekCM-Web-Application,代码行数:59,代码来源:LOM_IEEE_METS_dmdSec_ReaderWriter.cs

示例4: Deserialize

        /// <summary>
        /// Deserializes an ChangedItem from an XML file.
        /// </summary>
        /// <param name="reader">XMLReader where the ChangedItem is.</param>
        /// <returns>ChangedItem.</returns>
        public static ChangedItem Deserialize(XmlReader reader)
        {
            ChangedItem lResult = null;
            if (reader.IsStartElement(DTD.Error.ChangedItems.TagChangedItem))
            {
                lResult = new ChangedItem();
                string stringModelType = reader.GetAttribute(DTD.Error.ChangedItems.ChangedItem.TagType);
                ModelType modelType = Convert.StringTypeToMODELType(stringModelType);

                if (modelType == ModelType.Oid)
                {
                    lResult.Type = Convert.MODELTypeToStringType(ModelType.Oid);
                    lResult.ClassName = stringModelType;
                }
                else
                {
                    lResult.Type = stringModelType;
                    lResult.ClassName = string.Empty;
                }
                lResult.Name = reader.GetAttribute(DTD.Error.ChangedItems.ChangedItem.TagName);

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();

                    if (reader.IsStartElement(DTD.Error.ChangedItems.ChangedItem.TagChangedItemOldValue))
                    {
                        lResult.OldValue =  XMLChangedItemValueSerializer.Deserialize(reader.ReadSubtree(),lResult.Type, lResult.ClassName);
                        reader.ReadEndElement();
                    }

                    if (reader.IsStartElement(DTD.Error.ChangedItems.ChangedItem.TagChangedItemNewValue))
                    {
                        lResult.NewValue = XMLChangedItemValueSerializer.Deserialize(reader.ReadSubtree(), lResult.Type, lResult.ClassName);
                        reader.ReadEndElement();
                    }
                }
                else
                {
                    reader.Skip();
                }
            }
            else
            {
                throw new ArgumentException("Xml Reader don't have the ChangedItem in Start Element.", "XmlReader reader");
            }
            return lResult;
        }
开发者ID:sgon1853,项目名称:UPM_MDD_Thesis,代码行数:53,代码来源:ChangedItems.Serializer.cs

示例5: expandNamespace_function

        private void expandNamespace_function(TreeNodeCollection outNodes, string strSection, string strNamespace, XmlReader reader)
        {
            bool bContinue = reader.ReadToDescendant("function");
            while (bContinue)
            {
                NodeDocPythonFunction node = newnode(strSection, strNamespace, reader.GetAttribute("name"));
                outNodes.Add(node);

                bool bInstance = reader.GetAttribute("instance") == "true";
                node.bIsInstanceMethod = bInstance;
                string strSyntax = reader.GetAttribute("fullsyntax"); if (strSyntax != null && strSyntax != "") node.strFullSyntax = strSyntax;
                node.strDocumentation = getFunctionDocAndExample(reader.ReadSubtree()); //assumes doc before example

                if (this.emphasizeStaticness())
                {
                    if (!bInstance)
                    {
                        //change visible node text to emphasize static-ness
                        node.Text = node.strNamespacename + "." + node.strFunctionname;
                    }
                }
                bContinue = ReadToNextSibling(reader, "function");
            }

            reader.Close();
        }
开发者ID:downpoured,项目名称:lnzscript,代码行数:26,代码来源:DocumentationFromPythonXml.cs

示例6: ReadXml

 public override void ReadXml(XmlReader reader)
 {
     if (CheckEmptyNode(reader, "DCPType", Namespace))
         return;
     reader.MoveToContent();
     Http.ReadXml(reader.ReadSubtree());
 }
开发者ID:galchen,项目名称:brutile,代码行数:7,代码来源:DCPType.cs

示例7: ReadXml

        public void ReadXml(XmlReader reader)
        {
            if (reader.LocalName != "Envelope" && !reader.ReadToDescendant("Envelope", SoapEnvelopeNamespace))
                throw new InvalidDataException();

            XmlHelper.ParseXml(reader, new XmlParseSet
            {
                {"Header", () => XmlHelper.ParseXmlDictionary(reader.ReadSubtree(), this.Headers)},
                {"Body", () => XmlHelper.ParseXml(reader.ReadSubtree(), new XmlParseSet {
                    () => {
                        this.Namespace = reader.NamespaceURI;
                        this.Method = reader.LocalName;
                        XmlHelper.ParseXmlDictionary(reader, this.Arguments);
                }})}
            });
        }
开发者ID:kthompson,项目名称:Upnp,代码行数:16,代码来源:SoapEnvelope.cs

示例8: ReadXml

        public override void ReadXml(XmlReader reader)
        {
            Keyword.Clear();

            var subReader = reader.ReadSubtree();

            if (CheckEmptyNode(subReader, "KeywordList", string.Empty, true))
                return;

            while (!subReader.EOF)
            {
                subReader.MoveToContent();
                if (subReader.LocalName == "Keyword")
                {
                    var att = subReader.GetAttribute("vocabulary");
                    reader.ReadStartElement("Keyword");
                    var val = reader.ReadContentAsString();
                    reader.ReadEndElement();
                    Keyword.Add(new Keyword { Vocabulary = att, Value = val });
                }
                else
                {
                    subReader.ReadEndElement();
                }
            }

            reader.Skip();
        }
开发者ID:galchen,项目名称:brutile,代码行数:28,代码来源:KeywordList.cs

示例9: expandNamespace_function

        private void expandNamespace_function(TreeNodeCollection outNodes, TreeNode outInstanceMethods, string strSection, string strNamespace, XmlReader reader)
        {
            bool bContinue = reader.ReadToDescendant("function");
            while (bContinue)
            {

               // if (reader.GetAttribute("args") != null) MessageBox.Show("instance?");

                NodeDocLnzFunction node = new NodeDocLnzFunction(strSection, strNamespace, reader.GetAttribute("name"));

                bool bInstance = reader.GetAttribute("instance") == "true";
                node.bIsInstanceMethod = bInstance;
                string strArgs = reader.GetAttribute("args"); if (strArgs != null && strArgs != "") node.strArguments = strArgs;
                string strReturns = reader.GetAttribute("returns"); if (strReturns != null && strReturns != "") node.strReturns = strReturns;
                node.strDocumentationAndExample = getFunctionDocAndExample(reader.ReadSubtree()); //assumes doc before example

                if (bInstance)
                {
                    //MessageBox.Show("instance found");
                    outInstanceMethods.Nodes.Add(node);
                }
                else
                    outNodes.Add(node);

                bContinue = ReadToNextSibling(reader, "function");
            }
            reader.Close();
        }
开发者ID:downpoured,项目名称:lnzscript,代码行数:28,代码来源:DocumentationFromLnzXml.cs

示例10: Deserialize

        public static ServiceRequest Deserialize(XmlReader reader, ServiceRequest serviceRequest)
        {
            if (reader.IsStartElement(DTD.Request.TagServiceRequest))
            {
                if (serviceRequest == null)
                {
                    serviceRequest = new ServiceRequest();
                }

                serviceRequest.Class = reader.GetAttribute(DTD.Request.ServiceRequest.TagClass);
                serviceRequest.Name = reader.GetAttribute(DTD.Request.ServiceRequest.TagService);

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    serviceRequest.Arguments = XMLArgumentsSerializer.Deserialize(reader.ReadSubtree());
                }
                else
                {
                    reader.Skip();
                }
            }
            else
            {
                throw new ArgumentException("Xml Reader don't have the Service.Request in Start Element.", "XmlReader reader");
            }

            return serviceRequest;
        }
开发者ID:sgon1853,项目名称:UPM_MDD_Thesis,代码行数:29,代码来源:Service.Request.Serializer.cs

示例11: ProcessLinks

        public static void ProcessLinks(XmlReader reader, NpgsqlConnection connection)
        {
            var page_title = reader.GetAttribute("title");
            List<string> titles;
            XmlReader inner;
            inner = reader.ReadSubtree();
            titles = new List<string>();
            while (inner.ReadToFollowing("link")) titles.Add(inner.ReadElementContentAsString());

            if (titles.Count() == 0) return;

            // Now we have a list of titles construct a subquery to get the ID's
            // I could use this query, which looks nicer, but EXPLAIN says it costs a little bit more.
            // SELECT id FROM pages WHERE title IN ('Apple','ElementalAllotropes')
            // AND redirect IS NULL UNION SELECT p2.id FROM pages AS p1
            // JOIN pages AS p2 ON p1.title IN ('Apple','ElementalAllotropes') AND p2.title = p1.redirect AND p2.redirect IS NULL;
            var select_command_text = string.Format(PostgresSchema.LINK_ID_QUERY,
                                string.Join(",", (from val in Enumerable.Range(0, titles.Count)
                                                select string.Format(":title_{0}", val))));

            // Update our links to be the array of ID's using the subquery above
            var command = new NpgsqlCommand(string.Format("UPDATE pages SET links = ARRAY({0}) WHERE title = :title", select_command_text), connection);
            foreach (var val in Enumerable.Range(0, titles.Count)) command.Parameters.AddWithValue("title_"+val, titles[val]);
            command.Parameters.Add(new NpgsqlParameter("title", page_title));
            command.ExecuteNonQuery();
        }
开发者ID:orf,项目名称:Wikipedia-XML-Processor,代码行数:26,代码来源:InputLinksIntoDatabase.cs

示例12: getTreeRootedAtElementNode

        /// <summary>
        ///  return a TreeNode that is the root of a tree representing this Element node with descendants
        /// </summary>
        /// <param name="xmlDoc"></param>
        /// <returns></returns>
        private TreeNode getTreeRootedAtElementNode(XmlReader xmlDoc)
        {
            TreeNode MainTreeRoot = getSingleNode(xmlDoc);
            TreeNode Attributes = new TreeNode();
            Attributes.Text = "<Attributes>";

            while (xmlDoc.MoveToNextAttribute())
            {
                Attributes.Nodes.Add(getSingleNode(xmlDoc));
            }
            MainTreeRoot.Nodes.Add(Attributes);
            xmlDoc.Read();
            while(!xmlDoc.EOF)
            {
                if(xmlDoc.NodeType == XmlNodeType.Element)
                {
                    using (XmlReader childElement = xmlDoc.ReadSubtree())
                    {
                        childElement.Read();
                        MainTreeRoot.Nodes.Add(getTreeRootedAtElementNode(childElement));
                    }
                }

                else if(xmlDoc.NodeType == XmlNodeType.EndElement)
                {
                    return MainTreeRoot;
                }
                else
                {
                    MainTreeRoot.Nodes.Add(getSingleNode(xmlDoc));
                }
                xmlDoc.Read();
            }
            return MainTreeRoot;
        }
开发者ID:alex606,项目名称:cis300,代码行数:40,代码来源:MainGUI.cs

示例13: ParseLogs

 public bool ParseLogs()
 {
     try
     {
         foreach (string f in _root.Files)
         {
             _reader = new XmlTextReader(f);
             Console.WriteLine("Loading Log");
             while (_reader.Read())
             {
                 if (_reader.Name == "State")
                 {
                     Dictionary<String, String> attributes = GetAttributes();
                     _root.States.Add(new Model.PMState(attributes));
                     ParseState(_reader.ReadSubtree());
                 }
             }
         }
     }
     catch
     {
         return false;
     }
     return true;
 }
开发者ID:ajansen7,项目名称:Pointing-Magnifier,代码行数:25,代码来源:Controller.cs

示例14: ReadXml

        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> stream from which the object is deserialized.</param>
        public override void ReadXml(XmlReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            if (reader.LocalName == "DirectoryPath")
            {
                XmlReader subReader = reader.ReadSubtree();
                XPathDocument doc = new XPathDocument(subReader);
                var nav = doc.CreateNavigator();

                XPathNavigator iter = nav.SelectSingleNode("/DirectoryPath/Version");
                if (iter != null)
                {
                    long ver = iter.ValueAsLong;

                    if (ver == CurrentVersion)
                    {
                        ReadCurrentVersion(nav);
                    }
                    else
                    {
                        throw new NotSupportedException("Version not supported.");
                    }
                }
                else
                {
                    throw new NotSupportedException("Could not read version of DirectoryPath. ");
                }
            }
        }
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:35,代码来源:DirectoryPath.cs

示例15: TypeFilter

        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="configuration">The XML reader from which to get the configuration</param>
        public TypeFilter(XmlReader configuration)
        {
            if(configuration.NodeType != XmlNodeType.Element || configuration.Name != "type")
                throw new InvalidOperationException("The configuration element must be named 'type'");

            memberFilters = new List<MemberFilter>();
            name = configuration.GetAttribute("name");
            exposed = Convert.ToBoolean(configuration.GetAttribute("expose"), CultureInfo.InvariantCulture);

            // If not exposed, check for a required attribute which forces it to be exposed.  This allows a
            // way to expose it and indicate that it should always be exposed in the configuration file.
            if(!exposed)
            {
                required = Convert.ToBoolean(configuration.GetAttribute("required"), CultureInfo.InvariantCulture);

                if(required)
                    exposed = true;
            }

            XmlReader subtree = configuration.ReadSubtree();

            while(subtree.Read())
                if(subtree.NodeType == XmlNodeType.Element && subtree.Name == "member")
                    memberFilters.Add(new MemberFilter(subtree));

            subtree.Close();
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:33,代码来源:TypeFilter.cs


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