示例#1
0
 public void Remove(HTMLElement value)
 {
     List.Remove(value);
 }
示例#2
0
		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 &amp; 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;
		}
示例#3
0
 public bool Contains(HTMLElement value)
 {
     return(this.List.Contains(value));
 }
示例#4
0
 public void Insert(int index, HTMLElement value)
 {
     List.Insert(index, value);
 }
示例#5
0
        public int Add(HTMLElement value)
        {
            int index = this.List.Add(value);

            return(index);
        }
示例#6
0
 public int IndexOf(HTMLElement value)
 {
     return(this.List.IndexOf(value));
 }
		public void Remove(HTMLElement value)
		{
			List.Remove(value);
		}
		//Remove

		public void CopyTo(HTMLElement[] array, int index)
		{
			List.CopyTo(array, index);
		}
		public void Insert(int index, HTMLElement value)
		{
			List.Insert(index, value);
		}
		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;
		}