您的位置:首页 > Web前端 > JavaScript

【开源】dhtml.net 仿javascript访问HTML文档(1.1版)

2010-06-26 09:18 281 查看
本版本为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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐