/// <summary> /// Constructor for making an HtmlTag chunk with a Match. This ctor is for self closing tags. /// </summary> /// <param name="tag">A Match with a self closing tag</param> public HtmlTag(Match tag) : base(tag.Value, HtmlChunkType.Tag) { _isSelfClosing = HtmlParserHelper.IsSelfClosingTag(tag); setTagInfoInternal(HtmlParserHelper.GetTagName(tag)); _attributes = HtmlParserHelper.GetAttributesFromTag(tag); _id = _attributes.ContainsKey("id") ? _attributes["id"] : ""; }
/// <summary> /// Constructor for making an HtmlTag chunk with a Match. This ctor is for open and close tags with inner text. /// </summary> /// <param name="tag">The Match with the opening tag</param> /// <param name="outterText">The full text</param> public HtmlTag(Match tag, string outterText) : base(outterText, HtmlChunkType.Tag) { _isSelfClosing = false; setTagInfoInternal(HtmlParserHelper.GetTagName(tag)); _attributes = HtmlParserHelper.GetAttributesFromTag(tag); _id = _attributes.ContainsKey("id") ? _attributes["id"] : ""; }
/// <summary> /// Constructor for making an HtmlTag chunk with strings /// </summary> /// <param name="tag"></param> /// <param name="fullTagName"></param> /// <param name="isSelfClosing"></param> public HtmlTag(string tag) : base(tag, HtmlChunkType.Tag) { TagRegex tagReg = new TagRegex(); Match m = tagReg.Match(tag); if (m.Success) { _attributes = HtmlParserHelper.GetAttributesFromTag(m); _isSelfClosing = HtmlParserHelper.IsSelfClosingTag(m); setTagInfoInternal(HtmlParserHelper.GetTagName(m)); _id = _attributes.ContainsKey("id") ? _attributes["id"] : ""; } else { throw new ArgumentException("A valid tag is required", "tag"); } }