今天从phpclasses.org上发现的一个超牛的php类,这个类最特别的是可以用select语句来从xml和html文档中读取特定的数据。例如下面是一个例子:
<?php
/*
** htmlsql - example 1
**
** 一个查询的简单例子
*/
//包含类文件
include_once("../snoopy.class.php");
include_once("../htmlsql.class.php");
//创建对象
$wsql = new htmlsql();
// 连接上url
if (!$wsql->connect('url', '/')){
print 'error while connecting: ' . $wsql->error;
exit;
}
/* 执行查询
select * from a 读取phpchina.cn首页的html中的所有的<a>标记
*/
if (!$wsql->query('select * from a ')){
print "query error: " . $wsql->error;
exit;
}
// 输出结果:
foreach($wsql->fetch_array() as $row){
print_r($row);
/*
$row 是像下面的一个数组:
array (
[href] => /index.html
[tagname] => a
[text] => 首页
)
*/
}
?>
这个类的作者:jonas john
个人主页:http://www.jonasjohn.de/
年龄:20
新闻热点
疑难解答