예제 #1
0
        public DOMObject Find(string id)
        {
            DOMObject tag = null;

            for (int i = 0; i < Attributes.Count; i++)
            {
                if (Attributes[i].AttributeName != null && Attributes[i].AttributeName.Equals("id"))
                {
                    if (Attributes[i].Value.Equals(id))
                    {
                        return(this);
                    }
                }
            }


            for (int i = 0; i < Childs.Count; i++)
            {
                tag = Childs[i].Find(id);
                if (tag != null)
                {
                    return(tag);
                }
            }


            return(null);
        }
예제 #2
0
        public void Process()
        {
            ParseAttributes();

            for (int i = Index; i < Document.HtmlTokenizer.Tokens.Count; i++)
            {
                Token currentToken = Document.HtmlTokenizer.Tokens[i];
                if (currentToken.Type == Token.TokenType.BeginTag)
                {
                    DOMObject child = new DOMObject(Document)
                    {
                        Index  = i + 1,
                        Parent = this,
                        Token  = currentToken
                    };
                    Childs.Add(child);
                    if (!Global.HtmlTags.Contains(child.Token.Name))
                    {
                        continue;
                    }
                    child.Process();
                    i = Index;
                    continue;
                }

                if (currentToken.Type == Token.TokenType.Content || currentToken.Type == Token.TokenType.Special)
                {
                    currentToken.NameBuilder.Append("echo");
                    currentToken.ClearSpaces();
                    DOMObject child = new DOMObject(Document)
                    {
                        Index  = i + 1,
                        Parent = this,
                        Token  = currentToken
                    };
                    Childs.Add(child);
                    continue;
                }

                if (currentToken.Type == Token.TokenType.EndTag && Token.Name.Equals(currentToken.Name))
                {
                    Parent.Index = i;
                    return;
                }
            }
            if (Parent != null)
            {
                Parent.Index = Document.HtmlTokenizer.Tokens.Count;
            }
        }