/// <summary> /// 获得指定标签名称的元素对象 /// </summary> /// <param name="vName">元素标签名称</param> /// <returns>保存找到的元素的列表对象</returns> public HTMLElementList GetElementsByTagName(string vName) { HTMLElementList myList = new HTMLElementList(); if (this.Body != null) { this.Body.InnerGetElementsByTagName(vName, myList); } return(myList); }
internal virtual void InnerGetAllElement(HTMLElementList list) { foreach (HTMLElement element in myChildNodes) { list.Add(element); if (element is HTMLContainer) { (( HTMLContainer )element).InnerGetAllElement(list); } } }
/// <summary> /// 获得所有指定名称的元素 /// </summary> /// <param name="vName">名称</param> /// <param name="myList">保存获得到元素的列表</param> /// <returns>获得到元素的个数</returns> internal virtual int InnerGetElementsByName(string vName, HTMLElementList myList) { int iCount = 0; foreach (HTMLElement e in myChildNodes) { if (e.GetAttribute(StringConstAttributeName.Name) == vName) { myList.Add(e); iCount++; } if (e is HTMLContainer) { iCount += (( HTMLContainer)e).InnerGetElementsByName(vName, myList); } } return(iCount); }
/// <summary> /// 获得所有指定标签名称的元素 /// </summary> /// <param name="vTagName">指定的标签名称</param> /// <param name="myList">保存获得到元素的列表</param> /// <returns>获得到元素的个数</returns> internal virtual int InnerGetElementsByTagName(string vTagName, HTMLElementList myList) { int iCount = 0; foreach (HTMLElement e in myChildNodes) { if (e.TagName == vTagName) { myList.Add(e); iCount++; } if (e is HTMLContainer) { iCount += (( HTMLContainer)e).InnerGetElementsByTagName(vTagName, myList); } } return(iCount); }