Home > Backend Development > PHP Tutorial > 浅析php插件 Simple HTML DOM 用DOM方式处理HTML_PHP

浅析php插件 Simple HTML DOM 用DOM方式处理HTML_PHP

WBOY
Release: 2016-06-01 12:05:32
Original
826 people have browsed it

simple_html_dom插件
用dom处理html文件的利器
使用:
加载simple_html_dom.php文件
复制代码 代码如下:
require_once 'simple_html_dom.php'

new simple_html_dom对象
复制代码 代码如下:
$dom = new simple_html_dom()

加载html
复制代码 代码如下:
$dom->load($html);

find()方法
复制代码 代码如下:
$dom->find('div.lookLeftname', 0)->plaintext

class=‘lookLeftname'的div中的纯文本
复制代码 代码如下:
$dom->find('div.lookLeftname', 0)->innertext

class='lookLeftname'的div中的内部文本
plaintext 与innertext最常用的

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template