Example #1
0
 /// <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"] : "";
 }
Example #2
0
 /// <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"] : "";
 }
Example #3
0
        /// <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");
            }
        }
Example #4
0
        public HtmlDoc(string docHtml)
            : base(docHtml, HtmlChunkType.Doc)
        {
            //Check for the parser type directive
            DirectiveRegex drx  = new DirectiveRegex();
            Match          type = drx.Match(docHtml);

            //If we found it, make sure its actually our parser directive
            if (type.Success)
            {
                Dictionary <string, string> attrs = HtmlParserHelper.GetAttributesFromTag(type);
                //If its a parser directive, assign it, otherwise assign it the default parser
                _docType = attrs.ContainsKey("parser") ? attrs["parser"] : HtmlParser.DefaultParser;
            }
            else
            {
                _docType = HtmlParser.DefaultParser;
            }
        }