System.Xml.XmlReader.ReadToFollowing C# (CSharp) Method

ReadToFollowing() public method

public ReadToFollowing ( string name ) : bool
name string
return bool
        public virtual bool ReadToFollowing(string name)
        {
            if (name == null || name.Length == 0)
            {
                throw XmlConvert.CreateInvalidNameArgumentException(name, nameof(name));
            }
            // atomize name
            name = NameTable.Add(name);

            // find following element with that name
            while (Read())
            {
                if (NodeType == XmlNodeType.Element && Ref.Equal(name, Name))
                {
                    return true;
                }
            }
            return false;
        }

Same methods

XmlReader::ReadToFollowing ( string localName, string namespaceURI ) : bool

Usage Example

Example #1
0
        /// <summary>
        /// Parse the results of the Bing search
        /// </summary>
        /// <param name="reader">The xml reader containing the search results</param>
        public Collection<Article> ParseItems(XmlReader reader, Feed ownerFeed)
        {
            Collection<Article> results = new Collection<Article>();
            reader.ReadToFollowing("item");
            do
            {
                if (reader.ReadToFollowing("title"))
                {
                    string name = reader.ReadElementContentAsString();

                    if (reader.ReadToFollowing("link"))
                    {
                        string uri = reader.ReadElementContentAsString();

                        // Assign feed information to Article object.
                        Article newResult = new Article
                        {
                            ArticleTitle = name,
                            ArticleBaseURI = uri
                        };
                        // Safely add the search result to the collection.
                        lock (_lockObject)
                        {
                            results.Add(newResult);
                        }
                    }
                }
            } while (reader.ReadToFollowing("item"));
            return results;
        }
All Usage Examples Of System.Xml.XmlReader::ReadToFollowing