wiseparser 介绍
wiseparser 是一个 PHP 语言用来解析 HTML 文档的开发包。
示例代码:
require_once(‘treebuilder.PHP’);
$mytree = new Tree();
$mytree->parse_content(‘<div>Hello world</div>‘);
// or
$mytree->parse_file('http://www.google.com’);
$mytree->parse_file(‘myfile.htm’);
// To print HTML, just do:
echo $mytree;
// For those of you who familiar with HTML::Treebuilder, usage is almost the
same. Implemented methods:
// same as HTML::Element
Element->attr($attr, $value = null);
Element->tag($tag = null);
Element->look_down($keys);
Element->traverse($callback, $text_only=false);
Element->push_content($test_or_node, ..);
Element->unshift_content($test_or_node, ..);
Element->detach();
Element->preinsert($test_or_node, ..);
Element->postinsert($test_or_node, ..);
Element->as_HTML();
Element->as_text();
// plus one additional method:
Element->seek_n_destroy($keys); // same as
look_down()->detach()->__destruct();
// same as HTML::Treebuilder:
Tree->parse_content($content);
Tree->parse_file($filename_or_url);
wiseparser 官网
http://code.google.com/p/wiseparser/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。