private void OnAttribute(object sender, HtmlParserAttributeEventArgs e) { if (_currentElementRecord != null) { var currentElement = _currentElementRecord.Element; var a = AttributeNode.Create(currentElement, e.AttributeToken); List<AttributeNode> attributeCollection; if (currentElement.StartTag.IsComplete) attributeCollection = _currentElementRecord.EndTagAttributes; else attributeCollection = _currentElementRecord.StartTagAttributes; attributeCollection.Add(a); } }
void OnAttribute(object sender, HtmlParserAttributeEventArgs e) { var at = e.AttributeToken; ITextProvider text = _parser.Text; Debug.Assert(at.Start >= 0 && at.End >= 0); Log.AppendFormat("\tOnAttribute: @[{0} ... {1}] '{2}'\r\n\t\tHasName: {3}\r\n\t\tHasValue: {4}\r\n", at.Start, at.End, text.GetText(at), at.HasName(), at.HasValue()); if (at.HasName()) { Log.AppendFormat("\t\tName: @[{0} ... {1}]\r\n", at.NameToken.Start, at.NameToken.End); var nameToken = at.NameToken as NameToken; if (nameToken != null) { if (nameToken.HasPrefix()) { Log.AppendFormat("\t\t\tNamespace: {0} @[{1} ... {2}] '{3}'\r\n", nameToken.HasPrefix(), nameToken.PrefixRange.Start, nameToken.PrefixRange.End, text.GetText(nameToken.PrefixRange)); } else { Log.AppendFormat("\t\t\tNamespace: {0} @[{1} ... {2}]\r\n", nameToken.HasPrefix(), nameToken.PrefixRange.Start, nameToken.PrefixRange.End); } if (nameToken.HasName()) { Log.AppendFormat("\t\t\tName: {0} @[{1} ... {2}] '{3}'\r\n", nameToken.HasName(), nameToken.NameRange.Start, nameToken.NameRange.End, text.GetText(nameToken.NameRange)); } else { Log.AppendFormat("\t\t\tName: {0} @[{1} ... {2}]\r\n", nameToken.HasName(), nameToken.NameRange.Start, nameToken.NameRange.End); } } } if (at.HasValue()) { Log.AppendFormat("\t\tValue: @[{0} ... {1}] '{2}'\r\n", at.ValueToken.Start, at.ValueToken.End, text.GetText(at.ValueToken)); var tokens = at.ValueToken.Tokens; foreach (IHtmlToken t in tokens) { AppendToken("\t\t\t", t); } } Log.Append("\r\n"); }