public HtmlNode ParseElement(List <HtmlToken> tokens, ref int index) { HtmlElement elem = new HtmlElement(); elem.parentNode = current; current = elem; if (current is HtmlDocument) { elem.ownerDocument = current as HtmlDocument; } else { elem.ownerDocument = elem.parentNode.ownerDocument; } ReadType(tokens, index, TokenType.HtmlElement).OrThrow("Expect Element"); HtmlToken elemName = tokens[index]; elem.name = elemName; Move(tokens, ref index); while (ReadType(tokens, index, TokenType.HtmlAttributeName)) { HtmlAttribute attr = (HtmlAttribute)ParseAttribute(tokens, ref index); elem.attrs.Add(attr.attrName, attr.attrValue); Move(tokens, ref index); } if (ReadType(tokens, index, TokenType.HtmlSlash)) { Move(tokens, ref index); ReadType(tokens, index, TokenType.HtmlElementEnd).OrThrow("Expect >"); } else if (ReadType(tokens, index, TokenType.HtmlElementEnd)) { Move(tokens, ref index); ParseNodeList(tokens, ref index); ReadType(tokens, index, TokenType.HtmlElementBegin).OrThrow("Expect <"); Move(tokens, ref index); ReadType(tokens, index, TokenType.HtmlSlash).OrThrow("Expect /"); Move(tokens, ref index); ReadType(tokens, index, TokenType.HtmlElementClosed).OrThrow("Expect Element Close"); (elemName.value == tokens[index].value).OrThrow("Element Name needs match"); } current = current.parentNode; return(elem); }
public HtmlElement(HtmlToken _token) : base(_token) { }
public HtmlDocument(HtmlToken _token) : base(_token) { }
public HtmlNode(HtmlToken _token) { this.name = _token; }
public HtmlText(HtmlElement _elem, HtmlToken text) : base(text) { this.elem = _elem; this.text = text; }