Beispiel #1
0
        // Reads to the following element with the given Name.
        public virtual bool ReadToFollowing(string name)
        {
            if (name == null || name.Length == 0)
            {
                throw XmlExceptionHelper.CreateInvalidNameArgumentException(name, "name");
            }

            // atomize name
            name = this.NameTable.Add(name);

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

            return(false);
        }
Beispiel #2
0
        internal void CheckElement(string localName, string namespaceURI)
        {
            if (localName == null || localName.Length == 0)
            {
                throw XmlExceptionHelper.CreateInvalidNameArgumentException(localName, "localName");
            }

            if (namespaceURI == null)
            {
                throw new ArgumentNullException("namespaceURI");
            }

            if (this.NodeType != XmlNodeType.Element)
            {
                throw new XmlException(Res.Xml_InvalidNodeType, this.NodeType.ToString(), this as IXmlLineInfo);
            }

            if (this.LocalName != localName || this.NamespaceURI != namespaceURI)
            {
                throw new XmlException(Res.Xml_ElementNotFoundNs, new string[2] {
                    localName, namespaceURI
                }, this as IXmlLineInfo);
            }
        }
Beispiel #3
0
        // Reads to the next sibling of the current element with the given Name.
        public virtual bool ReadToNextSibling(string name)
        {
            if (name == null || name.Length == 0)
            {
                throw XmlExceptionHelper.CreateInvalidNameArgumentException(name, "name");
            }

            // atomize name
            name = this.NameTable.Add(name);

            // find the next sibling
            XmlNodeType nt;

            do
            {
                this.SkipSubtree();
                nt = this.NodeType;
                if (nt == XmlNodeType.Element && Ref.Equal(name, this.Name))
                {
                    return(true);
                }
            } while (nt != XmlNodeType.EndElement && !this.EOF);
            return(false);
        }