/**
         * Read the next element
         * @param balance_quotes If <code>true</code> string nodes are parsed
         * paying attention to single and double quotes, such that tag-like
         * strings are ignored if they are quoted.
         * @return Node - The next node
         */

        public Node ReadElement(bool balance_quotes)
        {
            try
            {
                if (nextParsedNode.Size > 0)
                {
                    node = nextParsedNode[0];
                    nextParsedNode.Remove(0);
                    return(node);
                }

                if (ReadNextLine())
                {
                    do
                    {
                        line = GetNextLine();
                    } while (line != null && line.Length == 0);
                }
                else if (dontReadNextLine)
                {
                    dontReadNextLine = false;
                }
                else
                {
                    posInLine = LastReadPosition + 1;
                }

                if (line == null)
                {
                    return(null);
                }

                if (BeginTag(line, posInLine))
                {
                    node = remarkNodeParser.Find(this, line, posInLine);
                    if (node != null)
                    {
                        return(node);
                    }

                    node = Tag.Find(this, line, posInLine);
                    if (node != null)
                    {
                        Tag tag = (Tag)node;
                        try
                        {
                            node = tag.Scan(parser.Scanners, url, this);
                            return(node);
                        }
                        catch (Exception e)
                        {
                            StringBuilder msgBuffer = new StringBuilder();
                            msgBuffer.Append(
                                "NodeReader.ReadElement() : Error occurred while trying to decipher the tag using scanners\n" +
                                "    Tag being processed : " + tag.TagName + "\n" +
                                "    Current Tag Line : " + tag.TagLine
                                );
                            AppendLineDetails(msgBuffer);
                            ParserException ex = new ParserException(msgBuffer.ToString(), e);

                            parser.Feedback.Error(msgBuffer.ToString(), ex);
                            throw ex;
                        }
                    }

                    node = EndTag.Find(line, posInLine);
                    if (node != null)
                    {
                        return(node);
                    }
                }
                else
                {
                    node = stringParser.Find(this, line, posInLine, balance_quotes);
                    if (node != null)
                    {
                        return(node);
                    }
                }

                return(null);
            }
            catch (Exception e)
            {
                StringBuilder msgBuffer =
                    new StringBuilder("NodeReader.ReadElement() : Error occurred while trying to read the next element,");
                AppendLineDetails(msgBuffer);
                msgBuffer.Append("\n Caused by:\n").Append(msgBuffer.ToString());
                ParserException ex = new ParserException(msgBuffer.ToString(), e);
                parser.Feedback.Error(msgBuffer.ToString(), ex);
                throw ex;
            }
        }