예제 #1
0
        /// <summary>
        /// Returns the next input node from the XML document, if it is a
        /// child element of the specified input node. This essentially
        /// the same as the <c>ReadElement(InputNode)</c> object
        /// except that this will not read the element if it does not have
        /// the name specified. This essentially acts as a peak function.
        /// </summary>
        /// <param name="from">
        /// This is the input node to read with.
        /// </param>
        /// <param name="name">
        /// This is the name expected from the next element.
        /// </param>
        /// <returns>
        /// This returns the next input node from the document.
        /// </returns>
        public InputNode ReadElement(InputNode from, String name)
        {
            if (!stack.IsRelevant(from))
            {
                return(null);
            }
            EventNode node = reader.Peek();

            while (node != null)
            {
                if (node.IsEnd())
                {
                    if (stack.Top() == from)
                    {
                        return(null);
                    }
                    else
                    {
                        stack.Pop();
                    }
                }
                else if (node.IsStart())
                {
                    if (IsName(node, name))
                    {
                        return(ReadElement(from));
                    }
                    break;
                }
                node = reader.Next();
                node = reader.Peek();
            }
            return(null);
        }
예제 #2
0
        /// <summary>
        /// Returns the next input node from the XML document, if it is a
        /// child element of the specified input node. This essentially
        /// determines whether the end tag has been read for the specified
        /// node, if so then null is returned. If however the specified
        /// node has not had its end tag read then this returns the next
        /// element, if that element is a child of the that node.
        /// </summary>
        /// <param name="from">
        /// This is the input node to read with.
        /// </param>
        /// <returns>
        /// This returns the next input node from the document.
        /// </returns>
        public InputNode ReadElement(InputNode from)
        {
            if (!stack.IsRelevant(from))
            {
                return(null);
            }
            EventNode node = reader.Next();

            while (node != null)
            {
                if (node.IsEnd())
                {
                    if (stack.Pop() == from)
                    {
                        return(null);
                    }
                }
                else if (node.IsStart())
                {
                    return(ReadStart(from, node));
                }
                node = reader.Next();
            }
            return(null);
        }
예제 #3
0
        /// <summary>
        /// This is used to convert the start element to an input node.
        /// This will push the created input node on to the stack. The
        /// input node created contains a reference to this reader. so
        /// that it can be used to read child elements and values.
        /// </summary>
        /// <param name="from">
        /// This is the parent element for the start event.
        /// </param>
        /// <param name="event">
        /// This is the start element to be wrapped.
        /// </param>
        /// <returns>
        /// This returns an input node for the given element.
        /// </returns>
        public InputNode ReadStart(InputNode from, EventNode node)
        {
            InputElement input = new InputElement(from, this, node);

            if (node.IsStart())
            {
                return(stack.Push(input));
            }
            return(input);
        }