本版本為dhtml.net 1.1版,如有疑問請發郵件給我(sqzhuyi@gmail.com)
本版本較1.0版更新如下:
1、解決了一些基本BUG
2、為Element添加了GetElementsByTagName,GetElementsByName,GetElementsClass方法
3、添加document和element的搜尋功能,支援類似jquery搜尋
樣本:
string html = @"<p id=p1><span>aaa</span>
<b>bbb</b><textarea><i>af</i></textarea>
<b class='b1'>b1b1b1</b><input type=checkbox /></p>";
Document doc = new Document(html);
ElementCollect els = doc.Search("#p1 b[class=b1]");
Document 成員如下:
屬性
public ElementCollect Elements |
擷取HTML文檔中的所有節點 |
public Element Body |
擷取body節點 |
public string Title |
擷取文檔title字串 |
public FormCollect Forms |
擷取文檔中所有form節點 |
public FrameCollect Frames |
擷取文檔中所有frame節點 |
public ScriptCollect Scripts |
擷取文檔中所有script元素 |
public ImageCollect Images |
擷取文檔中所有img元素 |
方法
public ElementCollect GetElementsByTagName(string tag) |
通過tagName擷取節點集合 |
public ElementCollect GetElementsByName(string name) |
通過節點name屬性擷取節點集合 |
public ElementCollect GetElementsByClass(string clas) |
通過節點class屬性擷取節點集合 |
public Element GetElementById(string id) |
通過節點id擷取該節點 |
public ElementCollect Search(string path) |
搜尋文檔中合格節點,運算式樣本:#div1 span a[class="over"] |
Element 成員如下:
屬性
public int Index |
當前節點在elements集合中的索引 |
public string Id |
節點ID |
public string Name |
節點name |
public string Class |
節點class |
public string Style |
節點style |
public string TagName |
節點tagName |
public AttributeCollect Attributes |
節點屬性集合 |
public string InnerHTML |
節點innerHTML |
public string OuterHTML |
節點outerHTML |
public Element PreviousSibling |
當前節點的上一個兄弟節點 |
public Element NextSibling |
當前節點的下一個兄弟節點 |
public Element PreviousElement |
當前節點所在集合中的上一個節點 |
public Element NextElement |
當前節點所在集合中的下一個節點 |
public Element ParentElement |
當前節點的父節點 |
public ElementCollect ChildElements |
當前節點的子節點集合 |
方法
public ElementCollect GetElementsByTagName(string tag) |
通過tagName擷取節點集合 |
public ElementCollect GetElementsByName(string name) |
通過節點name屬性擷取節點集合 |
public ElementCollect GetElementsByClass(string clas) |
通過節點class屬性擷取節點集合 |
public ElementCollect Search(string path) |
搜尋文檔中合格節點,運算式樣本:#div1 span a[class="over"] |
源碼下載:
http://download.csdn.net/source/2645389