public void Remove(HTMLElement value) { List.Remove(value); }
private HTMLElementCollection GetScripts(string HTML) { string strExpression; //= "(?i:(?:<(?<element>script[^/ >]*)(?:\s(?!/)+(?:(?<attr>[^=]+)=(?:""|')(?<attrv>[^""\']+)(" & "?:""|')))*)(?:[^/]*/>|[^/]{0}>(?<text>[\s\S]*)(?<close></\k<element>>+)))" //(?i: // (?<element>(?:<script // (?:\s* // (?: // (?<attr>[^=>]*?) // =(?:"|') // (?<attrv>[^"|']*?) // (?:"|') // ))* // ) // ( //(?(?=\s*?/>)\s*?/> //| // (?:\s*?> // (?:[\s\r\n]*?<!--)?(?<text>[\s\S]*?) // </script>)) // )) //) strExpression = "(?i:" + "\t(?<element>(?:<script" + "\t\t(?:\\s*" + "\t\t(?:" + "\t\t\t(?<attr>[^=>]*?)" + "\t\t\t=(?:\"|')" + "\t\t\t(?<attrv>[^\"|']*?)" + "\t\t\t(?:\"|')" + "\t\t))*" + " )" + "\t(" + "(?(?=\\s*?/>)\\s*?/>" + "|" + " (?:\\s*?>" + "\t(?:[\\s\\r\\n]*?<!--)?(?<text>[\\s\\S]*?)" + " </script>))" + "\t)" + "))"; System.Text.RegularExpressions.Regex oRE = new System.Text.RegularExpressions.Regex(strExpression, System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace | System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Singleline); string strGroup; HTMLElementCollection oCol = new HTMLElementCollection(); HTMLElement objElement; ArrayList objAttr = new ArrayList(); //Todo: the association between attr and attrv is a minor hack here... think of something better! int intAttr; foreach (System.Text.RegularExpressions.Match oMatch in oRE.Matches(HTML)) { objElement = null; for (int iGroup = 0; iGroup <= oMatch.Groups.Count - 1; iGroup++) { strGroup = oRE.GroupNameFromNumber(iGroup); if (strGroup == "attr") objAttr = new ArrayList(); intAttr = 1; foreach (System.Text.RegularExpressions.Capture oCapture in oMatch.Groups[iGroup].Captures) { switch (strGroup) { case "element": objElement = new HTMLElement(oCapture.Value); objElement.Raw = oMatch.Value; break; case "attr": objAttr.Add(oCapture.Value); break; case "attrv": if ((string)objAttr[intAttr] == "src") { //need to replace & with & (webresource.axd for IE6) objElement.Attributes.Add(objAttr[intAttr], System.Web.HttpUtility.HtmlDecode(oCapture.Value)); } else { objElement.Attributes.Add(objAttr[intAttr], oCapture.Value); } intAttr += 1; break; case "text": objElement.Text = oCapture.Value; break; } } } if ((objElement != null)) { oCol.Add(objElement); } } return oCol; }
public bool Contains(HTMLElement value) { return(this.List.Contains(value)); }
public void Insert(int index, HTMLElement value) { List.Insert(index, value); }
public int Add(HTMLElement value) { int index = this.List.Add(value); return(index); }
public int IndexOf(HTMLElement value) { return(this.List.IndexOf(value)); }
//Remove public void CopyTo(HTMLElement[] array, int index) { List.CopyTo(array, index); }
public bool Contains(HTMLElement value) { return this.List.Contains(value); }
public int IndexOf(HTMLElement value) { return this.List.IndexOf(value); }
public void AddRange(HTMLElement[] value) { for (int i = 0; i <= value.Length - 1; i++) { Add(value[i]); } }
public int Add(HTMLElement value) { int index = this.List.Add(value); return index; }