protected List <HTag> _MatchTag(string html) { var reg = new Regex(Values.HtmlMatch + "|" + Values.NoneHtmlMatch, RegexOptions.Compiled); var returnList = new List <HTag>(); foreach (Match partMatch in reg.Matches(html)) { var tc = partMatch.Groups["TC"].Value; var tn = partMatch.Groups["TN"].Value; var tp = partMatch.Groups["TP"].Value; var rs = partMatch.Groups["RS"].Value; var ts = partMatch.Groups["TS"].Value; //TextTag if (string.IsNullOrEmpty(tn)) { var element = new HTextTag(rs); returnList.Add(element); } //Tag else if (string.IsNullOrEmpty(ts)) { var properties = new List <HProp>(); foreach (Match propertyMatch in Regex.Matches(tp, Values.PropertiesMatch)) { var key = propertyMatch.Groups[1].Value; var value = propertyMatch.Groups[2].Value; properties.Add(new HProp(key, value)); } var element = new HTag(tn, properties) { Children = _MatchTag(tc) }; element.Children.ForEach(t => t.Parent = element); returnList.Add(element); } } return(returnList); }
protected List <HTag> _MatchTag(string HTML) { var ReturnList = new List <HTag>(); foreach (var Part in Regex.Matches(HTML, Values.HTMLMatch + "|" + Values.NoneHTMLMatch)) { var PartMatch = Part as Match; var TC = PartMatch.Groups["TC"].Value; var TN = PartMatch.Groups["TN"].Value; var TP = PartMatch.Groups["TP"].Value; var RS = PartMatch.Groups["RS"].Value; var TS = PartMatch.Groups["TS"].Value; //TextTag if (string.IsNullOrEmpty(TN)) { var Element = new HTextTag(RS); ReturnList.Add(Element); } //Tag else if (string.IsNullOrEmpty(TS)) { var Properties = new List <HProp>(); foreach (var PropertyPart in Regex.Matches(TP, Values.PropertiesMatch)) { var PropertyMatch = PropertyPart as Match; var Key = PropertyMatch.Groups[1].Value; var Value = PropertyMatch.Groups[2].Value; Properties.Add(new HProp(Key, Value)); } var Element = new HTag(TN, Properties); Element.Children = _MatchTag(TC); Element.Children.ForEach(t => t.Parent = Element); ReturnList.Add(Element); } } return(ReturnList); }