Beispiel #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);
            }
        }
Beispiel #2
0
 public bool Parse(StringStream stream)
 {
     try
     {
         stream.ExtractChar(); //remove startbrace
         // Get Name
         Key = stream.ExtractUntil(false, '\n', '\t', ' ', RIGHTBRACE);
         // Parse content
         if (ParseAttributes(stream))
         {
             ParseContent(stream);
         }
         return(true);
     }
     catch (Exception ex)
     {
         BigBoss.Debug.w(Logs.XML, "Exception while parsing node: " + this + " " + ex);
         return(false);
     }
 }