예제 #1
0
        /// <summary>
        /// Parses the element's child elements.
        /// </summary>
        /// <param name="buffer">The string buffer to parse.</param>
        /// <param name="readPosition">The read position to start from.</param>
        /// <returns>True if successful, false otherwise.</returns>
        private bool parseChildElements(NSFString buffer, ref int readPosition)
        {
            while (true)
            {
                if (!skipWhitespace(buffer, ref readPosition))
                {
                    return(false);
                }

                if (buffer.Length < readPosition + 2)
                {
                    return(false);
                }

                // Check for child elements
                if ((buffer[readPosition] == '<') && (buffer[readPosition + 1] != '/'))
                {
                    NSFXMLElement newElement = new NSFXMLElement();

                    if (!newElement.loadBuffer(buffer, ref readPosition))
                    {
                        return(false);
                    }

                    addChildElementBack(newElement);

                    continue;
                }

                return(true);
            }
        }
        /// <summary>
        /// Populates the document with xml formatted text in the specified buffer.
        /// </summary>
        /// <param name="buffer">The buffer to load.</param>
        /// <returns>True if successful, false otherwise.</returns>
        public bool loadBuffer(NSFString buffer)
        {
            errorStatus = ErrorStatus.NoError;

            rootElement     = null;
            bookmarkElement = null;
            currentElement  = null;

            rootElement = new NSFXMLElement();

            if (!rootElement.loadBuffer(buffer))
            {
                rootElement = null;
                errorStatus = ErrorStatus.ParseError;
                return(false);
            }

            bookmarkElement = rootElement;
            currentElement  = rootElement;

            return(true);
        }
        /// <summary>
        /// Parses the element's child elements.
        /// </summary>
        /// <param name="buffer">The string buffer to parse.</param>
        /// <param name="readPosition">The read position to start from.</param>
        /// <returns>True if successful, false otherwise.</returns>
        private bool parseChildElements(NSFString buffer, ref int readPosition)
        {
            while (true)
            {
                if (!skipWhitespace(buffer, ref readPosition))
                {
                    return false;
                }

                if (buffer.Length < readPosition + 2)
                {
                    return false;
                }

                // Check for child elements
                if ((buffer[readPosition] == '<') && (buffer[readPosition + 1] != '/'))
                {
                    NSFXMLElement newElement = new NSFXMLElement();

                    if (!newElement.loadBuffer(buffer, ref readPosition))
                    {
                        return false;
                    }

                    addChildElementBack(newElement);

                    continue;
                }

                return true;
            }
        }