Example #1
0
        /*
         * Returns whether node has sub-content
         */
        protected bool ParseAttributes(StringStream stream)
        {
            string str = stream.ExtractUntil(false, EQUALS, SLASH, RIGHTBRACE);

            switch (stream.ExtractChar())
            {
            // An attribute
            case EQUALS:
                // Treating attributes as subnodes with text content
                XMLNode attr = new XMLNode(this);
                attr.Key     = str;
                attr.Content = stream.ExtractBetween(QUOTE, QUOTE);
                Add(attr);
                // Parse more attributes
                return(ParseAttributes(stream));

            // End of attributes, no content
            case SLASH:
                stream.ExtractUntil(true, RIGHTBRACE);     // Remove right brace
                return(false);

            // End of attributes, with content
            case RIGHTBRACE:
            default:
                return(true);
            }
        }