public string ReadTagName() { if (this.state != HtmlReader.State.BeginTag) { this.AssertInTag(); throw new InvalidOperationException("Reader must be positioned at the beginning of a StartTag, EndTag or EmptyElementTag token"); } string result; if (this.parserToken.NameIndex != HtmlNameIndex.Unknown) { result = HtmlNameData.Names[(int)this.parserToken.NameIndex].Name; } else { if (this.parserToken.IsTagNameEnd) { return(this.parserToken.Name.GetString(int.MaxValue)); } StringBuildSink stringBuildSink = this.GetStringBuildSink(); this.parserToken.Name.WriteTo(stringBuildSink); do { this.ParseToken(); this.parserToken.Name.WriteTo(stringBuildSink); }while (!this.parserToken.IsTagNameEnd); result = stringBuildSink.ToString(); } this.state = HtmlReader.State.EndTagName; return(result); }
internal string AttributeReader_ReadCurrentAttributeName() { if (this.state != HtmlReader.State.BeginAttribute) { this.AssertInAttribute(); throw new InvalidOperationException("Reader must be positioned at the beginning of attribute."); } string result; if (this.parserToken.Attributes[this.currentAttribute].NameIndex != HtmlNameIndex.Unknown) { result = HtmlNameData.Names[(int)this.parserToken.Attributes[this.currentAttribute].NameIndex].Name; } else { if (this.parserToken.Attributes[this.currentAttribute].IsAttrNameEnd) { return(this.parserToken.Attributes[this.currentAttribute].Name.GetString(int.MaxValue)); } StringBuildSink stringBuildSink = this.GetStringBuildSink(); this.parserToken.Attributes[this.currentAttribute].Name.WriteTo(stringBuildSink); do { this.ParseToken(); this.currentAttribute = 0; this.parserToken.Attributes[this.currentAttribute].Name.WriteTo(stringBuildSink); }while (!this.parserToken.Attributes[0].IsAttrNameEnd); result = stringBuildSink.ToString(); } this.state = HtmlReader.State.EndAttributeName; return(result); }
internal string AttributeReader_ReadCurrentAttributeValue() { if (this.state != HtmlReader.State.BeginAttributeValue) { this.AssertInAttribute(); if (this.state > HtmlReader.State.BeginAttributeValue) { throw new InvalidOperationException("Reader must be positioned before attribute value"); } if (!this.SkipToAttributeValue()) { this.state = HtmlReader.State.EndAttribute; return(null); } } if (this.parserToken.Attributes[this.currentAttribute].IsAttrEnd) { return(this.parserToken.Attributes[this.currentAttribute].Value.GetString(int.MaxValue)); } StringBuildSink stringBuildSink = this.GetStringBuildSink(); this.parserToken.Attributes[this.currentAttribute].Value.WriteTo(stringBuildSink); do { this.ParseToken(); this.currentAttribute = 0; this.parserToken.Attributes[0].Value.WriteTo(stringBuildSink); }while (!this.parserToken.Attributes[0].IsAttrEnd); this.state = HtmlReader.State.EndAttribute; return(stringBuildSink.ToString()); }