发布于 2016-01-17 09:36:38 | 645 次阅读 | 评论: 0 | 来源: PHPERZ
| 名称 | 描述 | 
|---|---|
| object str_get_html ( string $content ) | 从字符串创建DOM对象 | 
| object file_get_html ( string $filename ) | 从URL或者文件创建DOM | 
| 名称 | 描述 | 
|---|---|
| 
			 void 
			__construct ( [string $filename] ) | 
			构造方法, 参数可以是文件名、URL、HTML字符串,或者不传参数。 | 
| 
			 string 
			plaintext | 
			返回提取的HTML文本内容. | 
| 
			 void 
			clear () | 
			释放对象占用的内存 | 
| 
			 void 
			load ( string $content ) | 
			加载字符串用于解析 | 
| 
			 string 
			save ( [string $filename] ) | 
			返回内部DOM树的字符串,如果传递了文件名参数,将把内部DOM树的字符串存储到文件 | 
| 
			 void 
			load_file ( string $filename ) | 
			加载一个文件或者URL内容用于解析 | 
| 
			 void 
			set_callback ( string $function_name ) | 
			设置回调函数 | 
| 
			 mixed 
			find ( string $selector [, int $index] ) | 
			使用css选择器查找一组元素.第二个参数是数组索引,从0开始。 没有第二个参数返回的是找的所有元素的数组,如果传递了第二个参数返回数组中索引位置的元素对象。  | 
		
| 名称 | 描述 | 
|---|---|
| 
			 string 
			[attribute] | 
			获取或者设置元素的属性值 | 
| 
			 string 
			tag | 
			获取或者设置元素的标签名 | 
| 
			 string 
			outertext | 
			获取或者设置元素的 outer HTML | 
| 
			 string 
			innertext | 
			获取或者设置元素的 inner HTML | 
| 
			 string 
			plaintext | 
			获取或者设置元素的纯文本 | 
| 
			 mixed 
			find ( string $selector [, int $index] ) | 
			使用css选择器查找一组元素.第二个参数是数组索引,从0开始。 没有第二个参数返回的是找的所有元素的数组,如果传递了第二个参数返回数组中索引位置的元素对象。  | 
		
| 名称 | 描述 | 
|---|---|
| 
			 mixed 
			$e->children ( [int $index] ) | 
			无参数时返回所有的后代元素数组,参数是具体后代元素数组的索引,如果传递了索引参数那么返回的是一个DOM对象而不是数组。 | 
| 
			 element 
			$e->parent () | 
			返回父元素 | 
| 
			 element 
			$e->first_child () | 
			返回第一个子元素,不存在就返回null | 
| 
			 element 
			$e->last_child () | 
			返回最后一个子元素,不存在就返回null | 
| 
			 element 
			$e->next_sibling () | 
			返回下一个同级元素,不存在就返回null | 
| 
			 element 
			$e->prev_sibling () | 
			返回上一个同级元素,不存在就返回null | 
| 驼峰命名的方法 | 对应的等效方法 | 
|---|---|
| 
			 array 
			$e->getAllAttributes () | 
			
			 array 
			$e->attr | 
		
| 
			 string 
			$e->getAttribute ( $name ) | 
			
			 string 
			$e->attribute | 
		
| 
			 void 
			$e->setAttribute ( $name, $value ) | 
			
			 void 
			$value = $e->attribute | 
		
| 
			 bool 
			$e->hasAttribute ( $name ) | 
			
			 bool 
			isset($e->attribute) | 
		
| 
			 void 
			$e->removeAttribute ( $name ) | 
			
			 void 
			$e->attribute = null | 
		
| 
			 element 
			$e->getElementById ( $id ) | 
			
			 mixed 
			$e->find ( "#$id", 0 ) | 
		
| 
			 mixed 
			$e->getElementsById ( $id [,$index] ) | 
			
			 mixed 
			$e->find ( "#$id" [, int $index] ) | 
		
| 
			 element 
			$e->getElementByTagName ($name ) | 
			
			 mixed 
			$e->find ( $name, 0 ) | 
		
| 
			 mixed 
			$e->getElementsByTagName ( $name [, $index] ) | 
			
			 mixed 
			$e->find ( $name [, int $index] ) | 
		
| 
			 element 
			$e->parentNode () | 
			
			 element 
			$e->parent () | 
		
| 
			 mixed 
			$e->childNodes ( [$index] ) | 
			
			 mixed 
			$e->children ( [int $index] ) | 
		
| 
			 element 
			$e->firstChild () | 
			
			 element 
			$e->first_child () | 
		
| 
			 element 
			$e->lastChild () | 
			
			 element 
			$e->last_child () | 
		
| 
			 element 
			$e->nextSibling () | 
			
			 element 
			$e->next_sibling () | 
		
| 
			 element 
			$e->previousSibling () | 
			
			 element 
			$e->prev_sibling () |