Beispiel #1
0
        public override bool MoveToChild(string localName, string namespaceURI)
        {
            if (!_current.Elements().Any())
            {
                return(false);
            }

            var fullName = localName;

            if (!string.IsNullOrEmpty(namespaceURI))
            {
                fullName = ResultWriter.PrefixFromNamespace(namespaceURI) + ":" + localName;
            }

            var list = new ElementList(_current.Elements());

            while (list.MoveNext())
            {
                if (list.Current.Name == fullName)
                {
                    _stack.Push(list);
                    return(SetCurrent(_stack.Peek().Current));
                }
            }
            return(false);
        }
Beispiel #2
0
        public override bool MoveToNext(string localName, string namespaceURI)
        {
            if (_stack.Count < 1 || _node == XPathNodeType.Text)
            {
                return(false);
            }

            var pos      = _stack.Peek().Position;
            var fullName = localName;

            if (!string.IsNullOrEmpty(namespaceURI))
            {
                fullName = ResultWriter.PrefixFromNamespace(namespaceURI) + ":" + localName;
            }

            while (_stack.Peek().MoveNext())
            {
                if (_stack.Peek().Current.Name == fullName)
                {
                    return(SetCurrent(_stack.Peek().Current));
                }
            }

            _stack.Peek().Position = pos;
            return(false);
        }
Beispiel #3
0
        public override string GetAttribute(string name, string namespaceURI)
        {
            var prefix = ResultWriter.PrefixFromNamespace(namespaceURI);

            if (!string.IsNullOrEmpty(prefix))
            {
                name = prefix + ":" + name;
            }
            return(_current.Attribute(name).Value);
        }
Beispiel #4
0
        /// <summary>
        /// Moves to the attribute with the specified <see cref="P:System.Xml.XmlReader.LocalName" /> and <see cref="P:System.Xml.XmlReader.NamespaceURI" />.
        /// </summary>
        /// <param name="name">The local name of the attribute.</param>
        /// <param name="ns">The namespace URI of the attribute.</param>
        /// <returns>
        /// <c>true</c> if the attribute is found; otherwise, <c>false</c>. If <c>false</c>, the reader's position does not change.
        /// </returns>
        public override bool MoveToAttribute(string name, string ns)
        {
            var fullName = name;

            if (!string.IsNullOrEmpty(ns))
            {
                fullName = ResultWriter.PrefixFromNamespace(ns) + ":" + name;
            }
            _attrs = _nodeEnum.Current.Attributes.GetEnumerator();
            while (_attrs.MoveNext())
            {
                if (_attrs.Current.Key == fullName)
                {
                    _node = XmlNodeType.Attribute;
                    return(true);
                }
            }

            MoveToElement();
            return(false);
        }
Beispiel #5
0
        public override bool MoveToAttribute(string localName, string namespaceURI)
        {
            var fullName = localName;

            if (!string.IsNullOrEmpty(namespaceURI))
            {
                fullName = ResultWriter.PrefixFromNamespace(namespaceURI) + ":" + localName;
            }
            _attrs = _current.Attributes().GetEnumerator();
            while (_attrs.MoveNext())
            {
                if (_attrs.Current.Name == fullName)
                {
                    _node      = XPathNodeType.Attribute;
                    _localName = localName;
                    _prefix    = ResultWriter.PrefixFromNamespace(namespaceURI);
                    return(true);
                }
            }

            _node = XPathNodeType.Element;
            return(false);
        }